-rw-r--r-- | korganizer/koeventviewer.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 0866939..2f538c4 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,240 +1,240 @@ | |||
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 <libkdepim/addresseeview.h> | 38 | #include <libkdepim/addresseeview.h> |
39 | #include <kabc/stdaddressbook.h> | 39 | #include <kabc/stdaddressbook.h> |
40 | 40 | ||
41 | #ifndef KORG_NODCOP | 41 | #ifndef KORG_NODCOP |
42 | #include <dcopclient.h> | 42 | #include <dcopclient.h> |
43 | #include "korganizer.h" | 43 | #include "korganizer.h" |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #include "actionmanager.h" | 45 | #include "actionmanager.h" |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | #include "koeventviewer.h" | 48 | #include "koeventviewer.h" |
49 | #ifndef KORG_NOKABC | 49 | #ifndef KORG_NOKABC |
50 | #include <kabc/stdaddressbook.h> | 50 | #include <kabc/stdaddressbook.h> |
51 | #define size count | 51 | #define size count |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #ifdef DESKTOP_VERSION | 54 | #ifdef DESKTOP_VERSION |
55 | #include <kabc/addresseedialog.h> | 55 | #include <kabc/addresseedialog.h> |
56 | #else //DESKTOP_VERSION | 56 | #else //DESKTOP_VERSION |
57 | #include <externalapphandler.h> | 57 | #include <externalapphandler.h> |
58 | #include <qtopia/qcopenvelope_qws.h> | 58 | #include <qtopia/qcopenvelope_qws.h> |
59 | #endif //DESKTOP_VERSION | 59 | #endif //DESKTOP_VERSION |
60 | 60 | ||
61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
62 | : QTextBrowser(parent,name) | 62 | : QTextBrowser(parent,name) |
63 | { | 63 | { |
64 | mSyncMode = false; | 64 | mSyncMode = false; |
65 | mColorMode = 0; | 65 | mColorMode = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEventViewer::~KOEventViewer() | 68 | KOEventViewer::~KOEventViewer() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEventViewer::setSource(const QString& n) | 72 | void KOEventViewer::setSource(const QString& n) |
73 | { | 73 | { |
74 | 74 | ||
75 | if ( n.left(3) == "uid" ) | 75 | if ( n.left(3) == "uid" ) |
76 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
77 | { | 77 | { |
78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
79 | KABC::AddressBook::Iterator it; | 79 | KABC::AddressBook::Iterator it; |
80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
81 | // LR I do not understand, why the uid string is different on zaurus and desktop | 81 | // LR I do not understand, why the uid string is different on zaurus and desktop |
82 | QString uid = "uid://"+(*it).uid(); | 82 | QString uid = "uid://"+(*it).uid(); |
83 | 83 | ||
84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
85 | if (n == uid ) { | 85 | if (n == uid ) { |
86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
87 | QDialog dia( this,"dia123", true ); | 87 | QDialog dia( this,"dia123", true ); |
88 | dia.setCaption( i18n("Details of attendee") ); | 88 | dia.setCaption( i18n("Details of attendee") ); |
89 | QVBoxLayout lay ( &dia ); | 89 | QVBoxLayout lay ( &dia ); |
90 | KPIM::AddresseeView av ( &dia ); | 90 | KPIM::AddresseeView av ( &dia ); |
91 | av.setAddressee( (*it) ); | 91 | av.setAddressee( (*it) ); |
92 | lay.addWidget( &av ); | 92 | lay.addWidget( &av ); |
93 | if ( QApplication::desktop()->width() < 480 ) | 93 | if ( QApplication::desktop()->width() < 480 ) |
94 | dia.resize( 220, 240); | 94 | dia.resize( 220, 240); |
95 | else { | 95 | else { |
96 | dia.resize( 400,400); | 96 | dia.resize( 400,400); |
97 | 97 | ||
98 | } | 98 | } |
99 | dia.exec(); | 99 | dia.exec(); |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | #else | 105 | #else |
106 | { | 106 | { |
107 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 107 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
108 | if (attendees.count()) { | 108 | if (attendees.count()) { |
109 | Attendee *a; | 109 | Attendee *a; |
110 | for(a=attendees.first();a;a=attendees.next()) { | 110 | for(a=attendees.first();a;a=attendees.next()) { |
111 | if ( "uid:"+a->uid() == n ) { | 111 | if ( "uid:"+a->uid() == n ) { |
112 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), ""); | 112 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 119 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
120 | // the result should now arrive through method insertAttendees | 120 | // the result should now arrive through method insertAttendees |
121 | //QString uid = "uid:"+(*it).uid(); | 121 | //QString uid = "uid:"+(*it).uid(); |
122 | #endif | 122 | #endif |
123 | if ( n.left(6) == "mailto" ) { | 123 | if ( n.left(6) == "mailto" ) { |
124 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 124 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
125 | #ifndef DESKTOP_VERSION | 125 | #ifndef DESKTOP_VERSION |
126 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 126 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
127 | e << n.mid(7); | 127 | e << n.mid(7); |
128 | #endif | 128 | #endif |
129 | 129 | ||
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | #ifndef KORG_NODCOP | 133 | #ifndef KORG_NODCOP |
134 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 134 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
135 | QString tmpStr; | 135 | QString tmpStr; |
136 | if (n.startsWith("mailto:")) { | 136 | if (n.startsWith("mailto:")) { |
137 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 137 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
138 | //emit showIncidence(n); | 138 | //emit showIncidence(n); |
139 | return; | 139 | return; |
140 | } else if (n.startsWith("uid:")) { | 140 | } else if (n.startsWith("uid:")) { |
141 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 141 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
142 | const QByteArray noParamData; | 142 | const QByteArray noParamData; |
143 | const QByteArray paramData; | 143 | const QByteArray paramData; |
144 | QByteArray replyData; | 144 | QByteArray replyData; |
145 | QCString replyTypeStr; | 145 | QCString replyTypeStr; |
146 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 146 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
147 | bool foundAbbrowser = PING_ABBROWSER; | 147 | bool foundAbbrowser = PING_ABBROWSER; |
148 | 148 | ||
149 | if (foundAbbrowser) { | 149 | if (foundAbbrowser) { |
150 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 150 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
151 | //client->send("kaddressbook","KAddressBookIface", | 151 | //client->send("kaddressbook","KAddressBookIface", |
152 | QDataStream arg(paramData, IO_WriteOnly); | 152 | QDataStream arg(paramData, IO_WriteOnly); |
153 | arg << n.mid(6); | 153 | arg << n.mid(6); |
154 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 154 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
155 | return; | 155 | return; |
156 | } else { | 156 | } else { |
157 | /* | 157 | /* |
158 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 158 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
159 | We start it without its main interface | 159 | We start it without its main interface |
160 | */ | 160 | */ |
161 | KIconLoader* iconLoader = new KIconLoader(); | 161 | KIconLoader* iconLoader = new KIconLoader(); |
162 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 162 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
163 | ActionManager::setStartedKAddressBook(true); | 163 | ActionManager::setStartedKAddressBook(true); |
164 | tmpStr = "kaddressbook --editor-only --uid "; | 164 | tmpStr = "kaddressbook --editor-only --uid "; |
165 | tmpStr += KProcess::quote(n.mid(6)); | 165 | tmpStr += KProcess::quote(n.mid(6)); |
166 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 166 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | } else { | 169 | } else { |
170 | //QTextBrowser::setSource(n); | 170 | //QTextBrowser::setSource(n); |
171 | } | 171 | } |
172 | #endif | 172 | #endif |
173 | } | 173 | } |
174 | 174 | ||
175 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 175 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
176 | { | 176 | { |
177 | int number=text.contains("\n"); | 177 | int number=text.contains("\n"); |
178 | QString str = "<" + tag + ">"; | 178 | QString str = "<" + tag + ">"; |
179 | QString tmpText=text; | 179 | QString tmpText=text; |
180 | QString tmpStr=str; | 180 | QString tmpStr=str; |
181 | if(number !=-1) | 181 | if(number !=-1) |
182 | { | 182 | { |
183 | if (number > 0) { | 183 | if (number > 0) { |
184 | int pos=0; | 184 | int pos=0; |
185 | QString tmp; | 185 | QString tmp; |
186 | for(int i=0;i<=number;i++) { | 186 | for(int i=0;i<=number;i++) { |
187 | pos=tmpText.find("\n"); | 187 | pos=tmpText.find("\n"); |
188 | tmp=tmpText.left(pos); | 188 | tmp=tmpText.left(pos); |
189 | tmpText=tmpText.right(tmpText.length()-pos-1); | 189 | tmpText=tmpText.right(tmpText.length()-pos-1); |
190 | tmpStr+=tmp+"<br>"; | 190 | tmpStr+=tmp+"<br>"; |
191 | } | 191 | } |
192 | } | 192 | } |
193 | else tmpStr += tmpText; | 193 | else tmpStr += tmpText; |
194 | tmpStr+="</" + tag + ">"; | 194 | tmpStr+="</" + tag + ">"; |
195 | mText.append(tmpStr); | 195 | mText.append(tmpStr); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | str += text + "</" + tag + ">"; | 199 | str += text + "</" + tag + ">"; |
200 | mText.append(str); | 200 | mText.append(str); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | void KOEventViewer::setColorMode( int m ) | 204 | void KOEventViewer::setColorMode( int m ) |
205 | { | 205 | { |
206 | mColorMode = m; | 206 | mColorMode = m; |
207 | } | 207 | } |
208 | void KOEventViewer::appendEvent(Event *event, int mode ) | 208 | void KOEventViewer::appendEvent(Event *event, int mode ) |
209 | { | 209 | { |
210 | mMailSubject = ""; | 210 | mMailSubject = ""; |
211 | mCurrentIncidence = event; | 211 | mCurrentIncidence = event; |
212 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 212 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
213 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 213 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
214 | if ( mode == 0 ) { | 214 | if ( mode == 0 ) { |
215 | addTag("h2",event->summary()); | 215 | addTag("h2",event->summary()); |
216 | } | 216 | } |
217 | else { | 217 | else { |
218 | if ( mColorMode == 1 ) { | 218 | if ( mColorMode == 1 ) { |
219 | mText +="<font color=\"#00A000\">"; | 219 | mText +="<font color=\"#00A000\">"; |
220 | } | 220 | } |
221 | if ( mColorMode == 2 ) { | 221 | if ( mColorMode == 2 ) { |
222 | mText +="<font color=\"#C00000\">"; | 222 | mText +="<font color=\"#C00000\">"; |
223 | } | 223 | } |
224 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 224 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
225 | if ( mode == 1 ) { | 225 | if ( mode == 1 ) { |
226 | addTag("h2",i18n( "Local: " ) +event->summary()); | 226 | addTag("h2",i18n( "Local: " ) +event->summary()); |
227 | } else { | 227 | } else { |
228 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 228 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
229 | } | 229 | } |
230 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 230 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
231 | if ( mColorMode ) | 231 | if ( mColorMode ) |
232 | mText += "</font>"; | 232 | mText += "</font>"; |
233 | } | 233 | } |
234 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 234 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
235 | if (event->cancelled ()) { | 235 | if (event->cancelled ()) { |
236 | mText +="<font color=\"#B00000\">"; | 236 | mText +="<font color=\"#B00000\">"; |
237 | addTag("i",i18n("This event has been cancelled!")); | 237 | addTag("i",i18n("This event has been cancelled!")); |
238 | mText.append("<br>"); | 238 | mText.append("<br>"); |
239 | mText += "</font>"; | 239 | mText += "</font>"; |
240 | mMailSubject += i18n("(cancelled)"); | 240 | mMailSubject += i18n("(cancelled)"); |