-rw-r--r-- | korganizer/koeventviewer.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index c0acf34..4df26a9 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,311 +1,316 @@ | |||
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 <q3cstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <q3whatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <QDesktopWidget> | ||
24 | #include <qlabel.h> | 25 | #include <qlabel.h> |
25 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | //Added by qt3to4: | ||
28 | #include <QKeyEvent> | ||
29 | #include <Q3PtrList> | ||
30 | #include <Q3VBoxLayout> | ||
26 | 31 | ||
27 | #include <klocale.h> | 32 | #include <klocale.h> |
28 | #include <kapplication.h> | 33 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 34 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 35 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 36 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
33 | #include <krun.h> | 38 | #include <krun.h> |
34 | #include <kglobal.h> | 39 | #include <kglobal.h> |
35 | #include <kprocess.h> | 40 | #include <kprocess.h> |
36 | #include "koprefs.h" | 41 | #include "koprefs.h" |
37 | 42 | ||
38 | #include <kabc/stdaddressbook.h> | 43 | #include <kabc/stdaddressbook.h> |
39 | 44 | ||
40 | #ifndef KORG_NODCOP | 45 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 46 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 47 | #include "korganizer.h" |
43 | #include "koprefs.h" | 48 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 49 | #include "actionmanager.h" |
45 | #endif | 50 | #endif |
46 | 51 | ||
47 | #include "koeventviewer.h" | 52 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 53 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 54 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 55 | //#define size count |
51 | //#endif | 56 | //#endif |
52 | 57 | ||
53 | #ifdef DESKTOP_VERSION | 58 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 59 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 60 | #include <kabc/addresseeview.h> |
56 | #include <qprinter.h> | 61 | #include <qprinter.h> |
57 | #include <qpainter.h> | 62 | #include <qpainter.h> |
58 | #include <qpaintdevicemetrics.h> | 63 | #include <q3paintdevicemetrics.h> |
59 | #else //DESKTOP_VERSION | 64 | #else //DESKTOP_VERSION |
60 | #include <qtopia/qcopenvelope_qws.h> | 65 | #include <qtopia/qcopenvelope_qws.h> |
61 | #endif //DESKTOP_VERSION | 66 | #endif //DESKTOP_VERSION |
62 | #include <externalapphandler.h> | 67 | #include <externalapphandler.h> |
63 | 68 | ||
64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 69 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
65 | : QTextBrowser(parent,name) | 70 | : Q3TextBrowser(parent,name) |
66 | { | 71 | { |
67 | mSyncMode = false; | 72 | mSyncMode = false; |
68 | mColorMode = 0; | 73 | mColorMode = 0; |
69 | } | 74 | } |
70 | 75 | ||
71 | KOEventViewer::~KOEventViewer() | 76 | KOEventViewer::~KOEventViewer() |
72 | { | 77 | { |
73 | } | 78 | } |
74 | 79 | ||
75 | void KOEventViewer::printMe() | 80 | void KOEventViewer::printMe() |
76 | { | 81 | { |
77 | #ifdef DESKTOP_VERSION | 82 | #ifdef DESKTOP_VERSION |
78 | 83 | ||
79 | KOPrintPrefs pp ( this ); | 84 | KOPrintPrefs pp ( this ); |
80 | if (!pp.exec() ) | 85 | if (!pp.exec() ) |
81 | return; | 86 | return; |
82 | int scaleval = pp.printMode() ; | 87 | int scaleval = pp.printMode() ; |
83 | 88 | ||
84 | QPrinter printer; | 89 | QPrinter printer; |
85 | if (!printer.setup() ) | 90 | if (!printer.setup() ) |
86 | return; | 91 | return; |
87 | QPainter p; | 92 | QPainter p; |
88 | p.begin ( &printer ); | 93 | p.begin ( &printer ); |
89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 94 | Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer ); |
90 | float dx, dy; | 95 | float dx, dy; |
91 | int wid = (m.width() * 9)/10; | 96 | int wid = (m.width() * 9)/10; |
92 | dx = (float) wid/(float)contentsWidth (); | 97 | dx = (float) wid/(float)contentsWidth (); |
93 | dy = (float)(m.height()) / (float)contentsHeight (); | 98 | dy = (float)(m.height()) / (float)contentsHeight (); |
94 | float scale; | 99 | float scale; |
95 | // scale to fit the width or height of the paper | 100 | // scale to fit the width or height of the paper |
96 | if ( dx < dy ) | 101 | if ( dx < dy ) |
97 | scale = dx; | 102 | scale = dx; |
98 | else | 103 | else |
99 | scale = dy; | 104 | scale = dy; |
100 | 105 | ||
101 | p.translate( m.width()/10,0 ); | 106 | p.translate( m.width()/10,0 ); |
102 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 107 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
103 | p.scale( scale, scale ); | 108 | p.scale( scale, scale ); |
104 | } | 109 | } |
105 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 110 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
106 | p.end(); | 111 | p.end(); |
107 | #endif | 112 | #endif |
108 | 113 | ||
109 | } | 114 | } |
110 | void KOEventViewer::setSource(const QString& n) | 115 | void KOEventViewer::setSource(const QString& n) |
111 | { | 116 | { |
112 | 117 | ||
113 | if ( n.left(8) == "todo_uid" ) { | 118 | if ( n.left(8) == "todo_uid" ) { |
114 | int midstr = 9; | 119 | int midstr = 9; |
115 | #ifdef DESKTOP_VERSION | 120 | #ifdef DESKTOP_VERSION |
116 | midstr = 11; | 121 | midstr = 11; |
117 | #endif | 122 | #endif |
118 | //qDebug("-%s- ", n.mid(midstr).latin1()); | 123 | //qDebug("-%s- ", n.mid(midstr).latin1()); |
119 | emit showIncidence( n.mid(midstr) ); | 124 | emit showIncidence( n.mid(midstr) ); |
120 | return; | 125 | return; |
121 | } | 126 | } |
122 | 127 | ||
123 | if ( n.left(3) == "uid" ) | 128 | if ( n.left(3) == "uid" ) |
124 | #ifdef DESKTOP_VERSION | 129 | #ifdef DESKTOP_VERSION |
125 | { | 130 | { |
126 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 131 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
127 | KABC::AddressBook::Iterator it; | 132 | KABC::AddressBook::Iterator it; |
128 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 133 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
129 | // LR I do not understand, why the uid string is different on zaurus and desktop | 134 | // LR I do not understand, why the uid string is different on zaurus and desktop |
130 | QString uid = "uid://"+(*it).uid(); | 135 | QString uid = "uid://"+(*it).uid(); |
131 | 136 | ||
132 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 137 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
133 | if (n == uid ) { | 138 | if (n == uid ) { |
134 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 139 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
135 | QDialog dia( this,"dia123", true ); | 140 | QDialog dia( this,"dia123", true ); |
136 | dia.setCaption( i18n("Details of attendee") ); | 141 | dia.setCaption( i18n("Details of attendee") ); |
137 | QVBoxLayout lay ( &dia ); | 142 | Q3VBoxLayout lay ( &dia ); |
138 | KABC::AddresseeView av ( &dia ); | 143 | KABC::AddresseeView av ( &dia ); |
139 | av.setAddressee( (*it) ); | 144 | av.setAddressee( (*it) ); |
140 | lay.addWidget( &av ); | 145 | lay.addWidget( &av ); |
141 | if ( QApplication::desktop()->width() < 480 ) | 146 | if ( QApplication::desktop()->width() < 480 ) |
142 | dia.resize( 220, 240); | 147 | dia.resize( 220, 240); |
143 | else { | 148 | else { |
144 | dia.resize( 400,400); | 149 | dia.resize( 400,400); |
145 | } | 150 | } |
146 | dia.exec(); | 151 | dia.exec(); |
147 | break; | 152 | break; |
148 | } | 153 | } |
149 | } | 154 | } |
150 | return; | 155 | return; |
151 | } | 156 | } |
152 | #else | 157 | #else |
153 | { | 158 | { |
154 | if ( "uid:organizer" == n ) { | 159 | if ( "uid:organizer" == n ) { |
155 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 160 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
156 | return; | 161 | return; |
157 | } | 162 | } |
158 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 163 | Q3PtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
159 | if (attendees.count()) { | 164 | if (attendees.count()) { |
160 | Attendee *a; | 165 | Attendee *a; |
161 | for(a=attendees.first();a;a=attendees.next()) { | 166 | for(a=attendees.first();a;a=attendees.next()) { |
162 | if ( "uid:"+a->uid() == n ) { | 167 | if ( "uid:"+a->uid() == n ) { |
163 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 168 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
164 | return; | 169 | return; |
165 | } | 170 | } |
166 | } | 171 | } |
167 | } | 172 | } |
168 | return; | 173 | return; |
169 | } | 174 | } |
170 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 175 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
171 | // the result should now arrive through method insertAttendees | 176 | // the result should now arrive through method insertAttendees |
172 | //QString uid = "uid:"+(*it).uid(); | 177 | //QString uid = "uid:"+(*it).uid(); |
173 | #endif | 178 | #endif |
174 | if ( n.left(6) == "mailto" ) { | 179 | if ( n.left(6) == "mailto" ) { |
175 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 180 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
176 | //#ifndef DESKTOP_VERSION | 181 | //#ifndef DESKTOP_VERSION |
177 | if ( n.mid(7,3) == "ALL" ) { | 182 | if ( n.mid(7,3) == "ALL" ) { |
178 | mailToAttendees( true ); | 183 | mailToAttendees( true ); |
179 | } else if ( n.mid(7,4) == "RSVP" ) { | 184 | } else if ( n.mid(7,4) == "RSVP" ) { |
180 | mailToAttendees( false ); | 185 | mailToAttendees( false ); |
181 | } else { | 186 | } else { |
182 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 187 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
183 | //QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 188 | //QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
184 | //e << n.mid(7); | 189 | //e << n.mid(7); |
185 | } | 190 | } |
186 | //#endif | 191 | //#endif |
187 | 192 | ||
188 | } | 193 | } |
189 | 194 | ||
190 | 195 | ||
191 | #ifndef KORG_NODCOP | 196 | #ifndef KORG_NODCOP |
192 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 197 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
193 | QString tmpStr; | 198 | QString tmpStr; |
194 | if (n.startsWith("mailto:")) { | 199 | if (n.startsWith("mailto:")) { |
195 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 200 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
196 | //emit showIncidence(n); | 201 | //emit showIncidence(n); |
197 | return; | 202 | return; |
198 | } else if (n.startsWith("uid:")) { | 203 | } else if (n.startsWith("uid:")) { |
199 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 204 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
200 | const QByteArray noParamData; | 205 | const QByteArray noParamData; |
201 | const QByteArray paramData; | 206 | const QByteArray paramData; |
202 | QByteArray replyData; | 207 | QByteArray replyData; |
203 | QCString replyTypeStr; | 208 | Q3CString replyTypeStr; |
204 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 209 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
205 | bool foundAbbrowser = PING_ABBROWSER; | 210 | bool foundAbbrowser = PING_ABBROWSER; |
206 | 211 | ||
207 | if (foundAbbrowser) { | 212 | if (foundAbbrowser) { |
208 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 213 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
209 | //client->send("kaddressbook","KAddressBookIface", | 214 | //client->send("kaddressbook","KAddressBookIface", |
210 | QDataStream arg(paramData, IO_WriteOnly); | 215 | QDataStream arg(paramData, QIODevice::WriteOnly); |
211 | arg << n.mid(6); | 216 | arg << n.mid(6); |
212 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 217 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
213 | return; | 218 | return; |
214 | } else { | 219 | } else { |
215 | /* | 220 | /* |
216 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 221 | 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 | 222 | We start it without its main interface |
218 | */ | 223 | */ |
219 | KIconLoader* iconLoader = new KIconLoader(); | 224 | KIconLoader* iconLoader = new KIconLoader(); |
220 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 225 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
221 | ActionManager::setStartedKAddressBook(true); | 226 | ActionManager::setStartedKAddressBook(true); |
222 | tmpStr = "kaddressbook --editor-only --uid "; | 227 | tmpStr = "kaddressbook --editor-only --uid "; |
223 | tmpStr += KProcess::quote(n.mid(6)); | 228 | tmpStr += KProcess::quote(n.mid(6)); |
224 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 229 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
225 | return; | 230 | return; |
226 | } | 231 | } |
227 | } else { | 232 | } else { |
228 | //QTextBrowser::setSource(n); | 233 | //QTextBrowser::setSource(n); |
229 | } | 234 | } |
230 | #endif | 235 | #endif |
231 | } | 236 | } |
232 | void KOEventViewer::mailToAttendees( bool all ) | 237 | void KOEventViewer::mailToAttendees( bool all ) |
233 | { | 238 | { |
234 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 239 | Q3PtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
235 | if (attendees.count() == 0) return; | 240 | if (attendees.count() == 0) return; |
236 | QStringList nameList; | 241 | QStringList nameList; |
237 | QStringList emailList; | 242 | QStringList emailList; |
238 | QStringList uidList; | 243 | QStringList uidList; |
239 | Attendee* a; | 244 | Attendee* a; |
240 | for(a=attendees.first();a;a=attendees.next()) { | 245 | for(a=attendees.first();a;a=attendees.next()) { |
241 | if ( !all && !a->RSVP() ) continue; | 246 | if ( !all && !a->RSVP() ) continue; |
242 | if (!a->email().isEmpty()) { | 247 | if (!a->email().isEmpty()) { |
243 | #ifndef DESKTOP_VERSION | 248 | #ifndef DESKTOP_VERSION |
244 | nameList.append (a->realName() ); | 249 | nameList.append (a->realName() ); |
245 | emailList.append (a->email() ); | 250 | emailList.append (a->email() ); |
246 | uidList.append (a->uid() ); | 251 | uidList.append (a->uid() ); |
247 | #else | 252 | #else |
248 | emailList.append(a->realName() +" <" + a->email() +">"); | 253 | emailList.append(a->realName() +" <" + a->email() +">"); |
249 | #endif | 254 | #endif |
250 | } | 255 | } |
251 | } | 256 | } |
252 | #ifndef DESKTOP_VERSION | 257 | #ifndef DESKTOP_VERSION |
253 | QString uid = "ComposeMailUIpick2"+mMailSubject; | 258 | QString uid = "ComposeMailUIpick2"+mMailSubject; |
254 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 259 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
255 | 260 | ||
256 | #else | 261 | #else |
257 | ExternalAppHandler::instance()->mailToMultipleContacts( emailList.join(","), mMailSubject ); | 262 | ExternalAppHandler::instance()->mailToMultipleContacts( emailList.join(","), mMailSubject ); |
258 | #endif | 263 | #endif |
259 | 264 | ||
260 | } | 265 | } |
261 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 266 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
262 | { | 267 | { |
263 | int number=text.contains("\n"); | 268 | int number=text.count("\n"); |
264 | QString str = "<" + tag + ">"; | 269 | QString str = "<" + tag + ">"; |
265 | QString tmpText=text; | 270 | QString tmpText=text; |
266 | QString tmpStr=str; | 271 | QString tmpStr=str; |
267 | if(number !=-1) | 272 | if(number !=-1) |
268 | { | 273 | { |
269 | if (number > 0) { | 274 | if (number > 0) { |
270 | int pos=0; | 275 | int pos=0; |
271 | QString tmp; | 276 | QString tmp; |
272 | for(int i=0;i<=number;i++) { | 277 | for(int i=0;i<=number;i++) { |
273 | pos=tmpText.find("\n"); | 278 | pos=tmpText.find("\n"); |
274 | tmp=tmpText.left(pos); | 279 | tmp=tmpText.left(pos); |
275 | tmpText=tmpText.right(tmpText.length()-pos-1); | 280 | tmpText=tmpText.right(tmpText.length()-pos-1); |
276 | tmpStr+=tmp+"<br>"; | 281 | tmpStr+=tmp+"<br>"; |
277 | } | 282 | } |
278 | } | 283 | } |
279 | else tmpStr += tmpText; | 284 | else tmpStr += tmpText; |
280 | tmpStr+="</" + tag + ">"; | 285 | tmpStr+="</" + tag + ">"; |
281 | mText.append(tmpStr); | 286 | mText.append(tmpStr); |
282 | } | 287 | } |
283 | else | 288 | else |
284 | { | 289 | { |
285 | str += text + "</" + tag + ">"; | 290 | str += text + "</" + tag + ">"; |
286 | mText.append(str); | 291 | mText.append(str); |
287 | } | 292 | } |
288 | } | 293 | } |
289 | 294 | ||
290 | void KOEventViewer::setColorMode( int m ) | 295 | void KOEventViewer::setColorMode( int m ) |
291 | { | 296 | { |
292 | mColorMode = m; | 297 | mColorMode = m; |
293 | } | 298 | } |
294 | void KOEventViewer::appendEvent(Event *event, int mode ) | 299 | void KOEventViewer::appendEvent(Event *event, int mode ) |
295 | { | 300 | { |
296 | mMailSubject = ""; | 301 | mMailSubject = ""; |
297 | mCurrentIncidence = event; | 302 | mCurrentIncidence = event; |
298 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 303 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
299 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); | 304 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); |
300 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 305 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
301 | if ( mode == 0 ) { | 306 | if ( mode == 0 ) { |
302 | addTag("h2",deTag(event->summary())); | 307 | addTag("h2",deTag(event->summary())); |
303 | formatReadOnly(event); | 308 | formatReadOnly(event); |
304 | } | 309 | } |
305 | else { | 310 | else { |
306 | if ( mColorMode == 1 ) { | 311 | if ( mColorMode == 1 ) { |
307 | mText +="<font color=\"#00A000\">"; | 312 | mText +="<font color=\"#00A000\">"; |
308 | } | 313 | } |
309 | if ( mColorMode == 2 ) { | 314 | if ( mColorMode == 2 ) { |
310 | mText +="<font color=\"#C00000\">"; | 315 | mText +="<font color=\"#C00000\">"; |
311 | } | 316 | } |
@@ -542,214 +547,214 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) | |||
542 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); | 547 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); |
543 | } else { | 548 | } else { |
544 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 549 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
545 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 550 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
546 | } | 551 | } |
547 | if ( !(event->alarmEnabled() ) ) { | 552 | if ( !(event->alarmEnabled() ) ) { |
548 | addTag("p", "<em>("+i18n("Enable alarm in resource settings") + ")</em>"); | 553 | addTag("p", "<em>("+i18n("Enable alarm in resource settings") + ")</em>"); |
549 | 554 | ||
550 | } | 555 | } |
551 | } | 556 | } |
552 | 557 | ||
553 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); | 558 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); |
554 | 559 | ||
555 | formatCategories(event); | 560 | formatCategories(event); |
556 | 561 | ||
557 | formatAttendees(event); | 562 | formatAttendees(event); |
558 | 563 | ||
559 | if ( KOPrefs::instance()->mEVshowCreated ) { | 564 | if ( KOPrefs::instance()->mEVshowCreated ) { |
560 | if(wideScreen ){ | 565 | if(wideScreen ){ |
561 | 566 | ||
562 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 567 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
563 | 568 | ||
564 | } else { | 569 | } else { |
565 | addTag("p",i18n("<b>Created: ") +" </b>"); | 570 | addTag("p",i18n("<b>Created: ") +" </b>"); |
566 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 571 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
567 | } | 572 | } |
568 | } | 573 | } |
569 | if ( KOPrefs::instance()->mEVshowChanged ) { | 574 | if ( KOPrefs::instance()->mEVshowChanged ) { |
570 | if(wideScreen ){ | 575 | if(wideScreen ){ |
571 | addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); | 576 | addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); |
572 | 577 | ||
573 | } else { | 578 | } else { |
574 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 579 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
575 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 580 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
576 | } | 581 | } |
577 | } | 582 | } |
578 | if ( event->relatedTo() ) { | 583 | if ( event->relatedTo() ) { |
579 | addTag("b",i18n("Parent todo:<br>")); | 584 | addTag("b",i18n("Parent todo:<br>")); |
580 | 585 | ||
581 | QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); | 586 | QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); |
582 | 587 | ||
583 | mText += t_name; | 588 | mText += t_name; |
584 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; | 589 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; |
585 | mText += deTag(event->relatedTo()->summary()); | 590 | mText += deTag(event->relatedTo()->summary()); |
586 | mText += "</a><br>"; | 591 | mText += "</a><br>"; |
587 | 592 | ||
588 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); | 593 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); |
589 | } | 594 | } |
590 | QPtrList<Incidence> Relations = event->relations(); | 595 | Q3PtrList<Incidence> Relations = event->relations(); |
591 | Incidence *to; | 596 | Incidence *to; |
592 | if ( Relations.first() ) | 597 | if ( Relations.first() ) |
593 | addTag("b",i18n("Sub todos:<br>")); | 598 | addTag("b",i18n("Sub todos:<br>")); |
594 | for (to=Relations.first();to;to=Relations.next()) { | 599 | for (to=Relations.first();to;to=Relations.next()) { |
595 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); | 600 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); |
596 | mText += t_name; | 601 | mText += t_name; |
597 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; | 602 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; |
598 | mText += deTag(to->summary()); | 603 | mText += deTag(to->summary()); |
599 | mText += "</a><br>"; | 604 | mText += "</a><br>"; |
600 | 605 | ||
601 | } | 606 | } |
602 | 607 | ||
603 | if ( KOPrefs::instance()->mEVshowDetails ) { | 608 | if ( KOPrefs::instance()->mEVshowDetails ) { |
604 | if (!event->description().isEmpty()) { | 609 | if (!event->description().isEmpty()) { |
605 | addTag("p",i18n("<b>Details: </b>")); | 610 | addTag("p",i18n("<b>Details: </b>")); |
606 | addTag("p",deTag(event->description())); | 611 | addTag("p",deTag(event->description())); |
607 | } | 612 | } |
608 | } | 613 | } |
609 | setText(mText); | 614 | setText(mText); |
610 | } | 615 | } |
611 | 616 | ||
612 | void KOEventViewer::formatCategories(Incidence *event) | 617 | void KOEventViewer::formatCategories(Incidence *event) |
613 | { | 618 | { |
614 | if (!event->categoriesStr().isEmpty()) { | 619 | if (!event->categoriesStr().isEmpty()) { |
615 | if (event->categories().count() == 1) { | 620 | if (event->categories().count() == 1) { |
616 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); | 621 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); |
617 | } else { | 622 | } else { |
618 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; | 623 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; |
619 | } | 624 | } |
620 | } | 625 | } |
621 | } | 626 | } |
622 | void KOEventViewer::formatAttendees(Incidence *event) | 627 | void KOEventViewer::formatAttendees(Incidence *event) |
623 | { | 628 | { |
624 | QPtrList<Attendee> attendees = event->attendees(); | 629 | Q3PtrList<Attendee> attendees = event->attendees(); |
625 | if (attendees.count()) { | 630 | if (attendees.count()) { |
626 | 631 | ||
627 | 632 | ||
628 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 633 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
629 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 634 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
630 | addTag("h3",i18n("Organizer")); | 635 | addTag("h3",i18n("Organizer")); |
631 | mText.append("<ul><li>"); | 636 | mText.append("<ul><li>"); |
632 | #ifndef KORG_NOKABC | 637 | #ifndef KORG_NOKABC |
633 | 638 | ||
634 | #ifdef DESKTOP_VERSION | 639 | #ifdef DESKTOP_VERSION |
635 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 640 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
636 | KABC::Addressee::List addressList; | 641 | KABC::Addressee::List addressList; |
637 | addressList = add_book->findByEmail(event->organizer()); | 642 | addressList = add_book->findByEmail(event->organizer()); |
638 | KABC::Addressee o = addressList.first(); | 643 | KABC::Addressee o = addressList.first(); |
639 | if (!o.isEmpty() && addressList.size()<2) { | 644 | if (!o.isEmpty() && addressList.size()<2) { |
640 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 645 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
641 | mText += o.formattedName(); | 646 | mText += o.formattedName(); |
642 | mText += "</a>\n"; | 647 | mText += "</a>\n"; |
643 | } else { | 648 | } else { |
644 | mText.append(event->organizer()); | 649 | mText.append(event->organizer()); |
645 | } | 650 | } |
646 | #else //DESKTOP_VERSION | 651 | #else //DESKTOP_VERSION |
647 | mText += "<a href=\"uid:organizer\">"; | 652 | mText += "<a href=\"uid:organizer\">"; |
648 | mText += event->organizer(); | 653 | mText += event->organizer(); |
649 | mText += "</a>\n"; | 654 | mText += "</a>\n"; |
650 | #endif //DESKTOP_VERSION | 655 | #endif //DESKTOP_VERSION |
651 | 656 | ||
652 | 657 | ||
653 | #else | 658 | #else |
654 | mText.append(event->organizer()); | 659 | mText.append(event->organizer()); |
655 | #endif | 660 | #endif |
656 | 661 | ||
657 | if (iconPath) { | 662 | if (!iconPath.isEmpty()) { |
658 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 663 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
659 | mText += "<IMG src=\"" + iconPath + "\">"; | 664 | mText += "<IMG src=\"" + iconPath + "\">"; |
660 | mText += "</a>\n"; | 665 | mText += "</a>\n"; |
661 | } | 666 | } |
662 | mText.append("</li></ul>"); | 667 | mText.append("</li></ul>"); |
663 | 668 | ||
664 | addTag("h3",i18n("Attendees")); | 669 | addTag("h3",i18n("Attendees")); |
665 | Attendee *a; | 670 | Attendee *a; |
666 | mText.append("<ul>"); | 671 | mText.append("<ul>"); |
667 | int a_count = 0; | 672 | int a_count = 0; |
668 | int a_count_nr = 0; | 673 | int a_count_nr = 0; |
669 | 674 | ||
670 | for(a=attendees.first();a;a=attendees.next()) { | 675 | for(a=attendees.first();a;a=attendees.next()) { |
671 | #ifndef KORG_NOKABC | 676 | #ifndef KORG_NOKABC |
672 | #ifdef DESKTOP_VERSION | 677 | #ifdef DESKTOP_VERSION |
673 | if (a->name().isEmpty()) { | 678 | if (a->name().isEmpty()) { |
674 | addressList = add_book->findByEmail(a->email()); | 679 | addressList = add_book->findByEmail(a->email()); |
675 | KABC::Addressee o = addressList.first(); | 680 | KABC::Addressee o = addressList.first(); |
676 | if (!o.isEmpty() && addressList.size()<2) { | 681 | if (!o.isEmpty() && addressList.size()<2) { |
677 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 682 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
678 | mText += o.formattedName(); | 683 | mText += o.formattedName(); |
679 | mText += "</a>\n"; | 684 | mText += "</a>\n"; |
680 | } else { | 685 | } else { |
681 | mText += "<li>"; | 686 | mText += "<li>"; |
682 | mText.append(a->email()); | 687 | mText.append(a->email()); |
683 | mText += "\n"; | 688 | mText += "\n"; |
684 | } | 689 | } |
685 | } else { | 690 | } else { |
686 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 691 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
687 | if (!a->name().isEmpty()) mText += a->name(); | 692 | if (!a->name().isEmpty()) mText += a->name(); |
688 | else mText += a->email(); | 693 | else mText += a->email(); |
689 | mText += "</a>\n"; | 694 | mText += "</a>\n"; |
690 | } | 695 | } |
691 | #else //DESKTOP_VERSION | 696 | #else //DESKTOP_VERSION |
692 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 697 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
693 | if (!a->name().isEmpty()) mText += a->name(); | 698 | if (!a->name().isEmpty()) mText += a->name(); |
694 | else mText += a->email(); | 699 | else mText += a->email(); |
695 | mText += "</a>\n"; | 700 | mText += "</a>\n"; |
696 | #endif //DESKTOP_VERSION | 701 | #endif //DESKTOP_VERSION |
697 | #else | 702 | #else |
698 | //qDebug("nokabc "); | 703 | //qDebug("nokabc "); |
699 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 704 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
700 | if (!a->name().isEmpty()) mText += a->name(); | 705 | if (!a->name().isEmpty()) mText += a->name(); |
701 | else mText += a->email(); | 706 | else mText += a->email(); |
702 | mText += "</a>\n"; | 707 | mText += "</a>\n"; |
703 | #endif | 708 | #endif |
704 | 709 | ||
705 | 710 | ||
706 | if (!a->email().isEmpty()) { | 711 | if (!a->email().isEmpty()) { |
707 | if (iconPath) { | 712 | if (!iconPath.isEmpty()) { |
708 | mText += "<a href=\"mailto:" + a->realName() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 713 | mText += "<a href=\"mailto:" + a->realName() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
709 | if ( a->RSVP() ) { | 714 | if ( a->RSVP() ) { |
710 | ++a_count_nr; | 715 | ++a_count_nr; |
711 | mText += "<IMG src=\"" + iconPath + "\">"; | 716 | mText += "<IMG src=\"" + iconPath + "\">"; |
712 | } | 717 | } |
713 | else { | 718 | else { |
714 | ++a_count; | 719 | ++a_count; |
715 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 720 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
716 | } | 721 | } |
717 | mText += "</a>\n"; | 722 | mText += "</a>\n"; |
718 | } | 723 | } |
719 | } | 724 | } |
720 | if (a->status() != Attendee::NeedsAction ) | 725 | if (a->status() != Attendee::NeedsAction ) |
721 | mText +="[" + a->statusStr() + "] "; | 726 | mText +="[" + a->statusStr() + "] "; |
722 | if (a->role() == Attendee::Chair ) | 727 | if (a->role() == Attendee::Chair ) |
723 | mText +="(" + a->roleStr().left(1) + ".)"; | 728 | mText +="(" + a->roleStr().left(1) + ".)"; |
724 | } | 729 | } |
725 | mText.append("</li></ul>"); | 730 | mText.append("</li></ul>"); |
726 | if ( (a_count+a_count_nr) > 1 ) { | 731 | if ( (a_count+a_count_nr) > 1 ) { |
727 | mText += "<a href=\"mailto:ALL\">"; | 732 | mText += "<a href=\"mailto:ALL\">"; |
728 | mText += i18n( "Mail to all" ); | 733 | mText += i18n( "Mail to all" ); |
729 | mText += "</a> ( "; | 734 | mText += "</a> ( "; |
730 | mText += "<IMG src=\"" + iconPath + "\">"; | 735 | mText += "<IMG src=\"" + iconPath + "\">"; |
731 | mText += i18n( " and " ); | 736 | mText += i18n( " and " ); |
732 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; | 737 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; |
733 | mText += "<br>\n"; | 738 | mText += "<br>\n"; |
734 | 739 | ||
735 | 740 | ||
736 | } | 741 | } |
737 | if ( a_count_nr > 1 ) { | 742 | if ( a_count_nr > 1 ) { |
738 | mText += "<a href=\"mailto:RSVP\">"; | 743 | mText += "<a href=\"mailto:RSVP\">"; |
739 | mText += i18n( "Mail to selected" ); | 744 | mText += i18n( "Mail to selected" ); |
740 | mText += "</a> ( "; | 745 | mText += "</a> ( "; |
741 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); | 746 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); |
742 | mText += "<br>\n"; | 747 | mText += "<br>\n"; |
743 | } | 748 | } |
744 | } | 749 | } |
745 | 750 | ||
746 | } | 751 | } |
747 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 752 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
748 | { | 753 | { |
749 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 754 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
750 | QString text_d = i18n("Journal from: "); | 755 | QString text_d = i18n("Journal from: "); |
751 | if ( !jour->summary().isEmpty() ) | 756 | if ( !jour->summary().isEmpty() ) |
752 | text_d = jour->summary(); | 757 | text_d = jour->summary(); |
753 | if (mode == 0 ) { | 758 | if (mode == 0 ) { |
754 | addTag("h2", text_d ); | 759 | addTag("h2", text_d ); |
755 | } | 760 | } |
@@ -817,52 +822,52 @@ void KOEventViewer::setEvent(Event *event) | |||
817 | if ( mSyncMode ) | 822 | if ( mSyncMode ) |
818 | appendEvent(event, 1); | 823 | appendEvent(event, 1); |
819 | else | 824 | else |
820 | appendEvent(event); | 825 | appendEvent(event); |
821 | } | 826 | } |
822 | 827 | ||
823 | void KOEventViewer::addEvent(Event *event) | 828 | void KOEventViewer::addEvent(Event *event) |
824 | { | 829 | { |
825 | if ( mSyncMode ) | 830 | if ( mSyncMode ) |
826 | appendEvent(event, 2); | 831 | appendEvent(event, 2); |
827 | else | 832 | else |
828 | appendEvent(event); | 833 | appendEvent(event); |
829 | } | 834 | } |
830 | 835 | ||
831 | void KOEventViewer::clearEvents(bool now) | 836 | void KOEventViewer::clearEvents(bool now) |
832 | { | 837 | { |
833 | mText = ""; | 838 | mText = ""; |
834 | if (now) setText(mText); | 839 | if (now) setText(mText); |
835 | } | 840 | } |
836 | 841 | ||
837 | void KOEventViewer::addText(QString text) | 842 | void KOEventViewer::addText(QString text) |
838 | { | 843 | { |
839 | mText.append(text); | 844 | mText.append(text); |
840 | setText(mText); | 845 | setText(mText); |
841 | } | 846 | } |
842 | QString KOEventViewer::deTag(QString text) | 847 | QString KOEventViewer::deTag(QString text) |
843 | { | 848 | { |
844 | #if QT_VERSION >= 0x030000 | 849 | #if QT_VERSION >= 0x030000 |
845 | text.replace( '<' , "<" ); | 850 | text.replace( '<' , "<" ); |
846 | text.replace( '>' , ">" ); | 851 | text.replace( '>' , ">" ); |
847 | #else | 852 | #else |
848 | if ( text.find ('<') >= 0 ) { | 853 | if ( text.find ('<') >= 0 ) { |
849 | text.replace( QRegExp("<") , "<" ); | 854 | text.replace( QRegExp("<") , "<" ); |
850 | } | 855 | } |
851 | if ( text.find ('>') >= 0 ) { | 856 | if ( text.find ('>') >= 0 ) { |
852 | text.replace( QRegExp(">") , ">" ); | 857 | text.replace( QRegExp(">") , ">" ); |
853 | } | 858 | } |
854 | #endif | 859 | #endif |
855 | return text; | 860 | return text; |
856 | } | 861 | } |
857 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) | 862 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) |
858 | { | 863 | { |
859 | switch ( e->key() ) { | 864 | switch ( e->key() ) { |
860 | case Qt::Key_Return: | 865 | case Qt::Key_Return: |
861 | case Qt::Key_Enter : | 866 | case Qt::Key_Enter : |
862 | e->ignore(); | 867 | e->ignore(); |
863 | break; | 868 | break; |
864 | default: | 869 | default: |
865 | QTextBrowser::keyPressEvent ( e ); | 870 | Q3TextBrowser::keyPressEvent ( e ); |
866 | break; | 871 | break; |
867 | } | 872 | } |
868 | } | 873 | } |