-rw-r--r-- | kmicromail/viewmail.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 7cf5c8e..0b4c322 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -1,413 +1,414 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include "composemail.h" | 2 | #include "composemail.h" |
3 | #include "viewmail.h" | 3 | #include "viewmail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/settings.h> | 5 | #include <libmailwrapper/settings.h> |
6 | #include <libmailwrapper/abstractmail.h> | 6 | #include <libmailwrapper/abstractmail.h> |
7 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
8 | #include <kapplication.h> | 8 | #include <kapplication.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/odebug.h> | 11 | //#include <opie2/odebug.h> |
12 | //#include <opie2/ofiledialog.h> | 12 | //#include <opie2/ofiledialog.h> |
13 | //#include <opie2/oimagescrollview.h> | 13 | //#include <opie2/oimagescrollview.h> |
14 | 14 | ||
15 | #include <kfiledialog.h> | 15 | #include <kfiledialog.h> |
16 | #include <kdialog.h> | 16 | #include <kdialog.h> |
17 | 17 | ||
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | 19 | ||
20 | /* QT */ | 20 | /* QT */ |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | #include <kglobal.h> | ||
30 | 31 | ||
31 | //using namespace Opie::Ui; | 32 | //using namespace Opie::Ui; |
32 | //using namespace Opie::Core; | 33 | //using namespace Opie::Core; |
33 | 34 | ||
34 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 35 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
35 | const QString&fsize,int num,const QValueList<int>&path) | 36 | const QString&fsize,int num,const QValueList<int>&path) |
36 | : QListViewItem(parent,after),_partNum(num) | 37 | : QListViewItem(parent,after),_partNum(num) |
37 | { | 38 | { |
38 | _path=path; | 39 | _path=path; |
39 | setText(0, mime); | 40 | setText(0, mime); |
40 | setText(1, desc); | 41 | setText(1, desc); |
41 | setText(2, file); | 42 | setText(2, file); |
42 | setText(3, fsize); | 43 | setText(3, fsize); |
43 | } | 44 | } |
44 | 45 | ||
45 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 46 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
46 | const QString&fsize,int num,const QValueList<int>&path) | 47 | const QString&fsize,int num,const QValueList<int>&path) |
47 | : QListViewItem(parent,after),_partNum(num) | 48 | : QListViewItem(parent,after),_partNum(num) |
48 | { | 49 | { |
49 | _path=path; | 50 | _path=path; |
50 | setText(0, mime); | 51 | setText(0, mime); |
51 | setText(1, desc); | 52 | setText(1, desc); |
52 | setText(2, file); | 53 | setText(2, file); |
53 | setText(3, fsize); | 54 | setText(3, fsize); |
54 | } | 55 | } |
55 | 56 | ||
56 | bool AttachItem::isParentof(const QValueList<int>&path) | 57 | bool AttachItem::isParentof(const QValueList<int>&path) |
57 | { | 58 | { |
58 | /* if not set, then no parent */ | 59 | /* if not set, then no parent */ |
59 | if (path.count()==0||_path.count()==0) return false; | 60 | if (path.count()==0||_path.count()==0) return false; |
60 | /* the parent must have one digit less then a child */ | 61 | /* the parent must have one digit less then a child */ |
61 | if (path.count()!=_path.count()+1) return false; | 62 | if (path.count()!=_path.count()+1) return false; |
62 | for (unsigned int i=0; i < _path.count();++i) | 63 | for (unsigned int i=0; i < _path.count();++i) |
63 | { | 64 | { |
64 | if (_path[i]!=path[i]) return false; | 65 | if (_path[i]!=path[i]) return false; |
65 | } | 66 | } |
66 | return true; | 67 | return true; |
67 | } | 68 | } |
68 | 69 | ||
69 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 70 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
70 | { | 71 | { |
71 | QListViewItemIterator it( attachments ); | 72 | QListViewItemIterator it( attachments ); |
72 | for ( ; it.current(); ++it ) | 73 | for ( ; it.current(); ++it ) |
73 | { | 74 | { |
74 | AttachItem*ati = (AttachItem*)it.current(); | 75 | AttachItem*ati = (AttachItem*)it.current(); |
75 | if (ati->isParentof(path)) return ati; | 76 | if (ati->isParentof(path)) return ati; |
76 | } | 77 | } |
77 | return 0; | 78 | return 0; |
78 | } | 79 | } |
79 | 80 | ||
80 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 81 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
81 | { | 82 | { |
82 | if (!parent) return 0; | 83 | if (!parent) return 0; |
83 | AttachItem* item = (AttachItem*)parent->firstChild(); | 84 | AttachItem* item = (AttachItem*)parent->firstChild(); |
84 | if (!item) return item; | 85 | if (!item) return item; |
85 | AttachItem*temp=0; | 86 | AttachItem*temp=0; |
86 | while( (temp=(AttachItem*)item->nextSibling())) | 87 | while( (temp=(AttachItem*)item->nextSibling())) |
87 | { | 88 | { |
88 | item = temp; | 89 | item = temp; |
89 | } | 90 | } |
90 | return item; | 91 | return item; |
91 | } | 92 | } |
92 | 93 | ||
93 | void ViewMail::setBody(const RecBodyP&body ) | 94 | void ViewMail::setBody(const RecBodyP&body ) |
94 | { | 95 | { |
95 | 96 | ||
96 | m_body = body; | 97 | m_body = body; |
97 | m_mail[2] = body->Bodytext(); | 98 | m_mail[2] = body->Bodytext(); |
98 | attachbutton->setEnabled(body->Parts().count()>0); | 99 | attachbutton->setEnabled(body->Parts().count()>0); |
99 | attachments->setEnabled(body->Parts().count()>0); | 100 | attachments->setEnabled(body->Parts().count()>0); |
100 | if (body->Parts().count()==0) | 101 | if (body->Parts().count()==0) |
101 | { | 102 | { |
102 | return; | 103 | return; |
103 | } | 104 | } |
104 | AttachItem * curItem=0; | 105 | AttachItem * curItem=0; |
105 | AttachItem * parentItem = 0; | 106 | AttachItem * parentItem = 0; |
106 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 107 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
107 | QString desc,fsize; | 108 | QString desc,fsize; |
108 | double s = body->Description()->Size(); | 109 | double s = body->Description()->Size(); |
109 | int w; | 110 | int w; |
110 | w=0; | 111 | w=0; |
111 | 112 | ||
112 | while (s>1024) | 113 | while (s>1024) |
113 | { | 114 | { |
114 | s/=1024; | 115 | s/=1024; |
115 | ++w; | 116 | ++w; |
116 | if (w>=2) break; | 117 | if (w>=2) break; |
117 | } | 118 | } |
118 | 119 | ||
119 | QString q=""; | 120 | QString q=""; |
120 | switch(w) | 121 | switch(w) |
121 | { | 122 | { |
122 | case 1: | 123 | case 1: |
123 | q="k"; | 124 | q="k"; |
124 | break; | 125 | break; |
125 | case 2: | 126 | case 2: |
126 | q="M"; | 127 | q="M"; |
127 | break; | 128 | break; |
128 | default: | 129 | default: |
129 | break; | 130 | break; |
130 | } | 131 | } |
131 | 132 | ||
132 | { | 133 | { |
133 | /* I did not found a method to make a CONTENT reset on a QTextStream | 134 | /* I did not found a method to make a CONTENT reset on a QTextStream |
134 | so I use this construct that the stream will re-constructed in each | 135 | so I use this construct that the stream will re-constructed in each |
135 | loop. To let it work, the textstream is packed into a own area of | 136 | loop. To let it work, the textstream is packed into a own area of |
136 | code is it will be destructed after finishing its small job. | 137 | code is it will be destructed after finishing its small job. |
137 | */ | 138 | */ |
138 | QTextOStream o(&fsize); | 139 | QTextOStream o(&fsize); |
139 | if (w>0) o.precision(2); else o.precision(0); | 140 | if (w>0) o.precision(2); else o.precision(0); |
140 | o.setf(QTextStream::fixed); | 141 | o.setf(QTextStream::fixed); |
141 | o << s << " " << q << "Byte"; | 142 | o << s << " " << q << "Byte"; |
142 | } | 143 | } |
143 | 144 | ||
144 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 145 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
145 | QString filename = ""; | 146 | QString filename = ""; |
146 | 147 | ||
147 | for (unsigned int i = 0; i < body->Parts().count();++i) | 148 | for (unsigned int i = 0; i < body->Parts().count();++i) |
148 | { | 149 | { |
149 | filename = ""; | 150 | filename = ""; |
150 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 151 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
151 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 152 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
152 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 153 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
153 | { | 154 | { |
154 | if (it.key().lower()=="name") | 155 | if (it.key().lower()=="name") |
155 | { | 156 | { |
156 | filename=it.data(); | 157 | filename=it.data(); |
157 | } | 158 | } |
158 | } | 159 | } |
159 | s = body->Parts()[i]->Size(); | 160 | s = body->Parts()[i]->Size(); |
160 | w = 0; | 161 | w = 0; |
161 | while (s>1024) | 162 | while (s>1024) |
162 | { | 163 | { |
163 | s/=1024; | 164 | s/=1024; |
164 | ++w; | 165 | ++w; |
165 | if (w>=2) break; | 166 | if (w>=2) break; |
166 | } | 167 | } |
167 | switch(w) | 168 | switch(w) |
168 | { | 169 | { |
169 | case 1: | 170 | case 1: |
170 | q="k"; | 171 | q="k"; |
171 | break; | 172 | break; |
172 | case 2: | 173 | case 2: |
173 | q="M"; | 174 | q="M"; |
174 | break; | 175 | break; |
175 | default: | 176 | default: |
176 | q=""; | 177 | q=""; |
177 | break; | 178 | break; |
178 | } | 179 | } |
179 | QTextOStream o(&fsize); | 180 | QTextOStream o(&fsize); |
180 | if (w>0) o.precision(2); else o.precision(0); | 181 | if (w>0) o.precision(2); else o.precision(0); |
181 | o.setf(QTextStream::fixed); | 182 | o.setf(QTextStream::fixed); |
182 | o << s << " " << q << "Byte"; | 183 | o << s << " " << q << "Byte"; |
183 | desc = body->Parts()[i]->Description(); | 184 | desc = body->Parts()[i]->Description(); |
184 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 185 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
185 | if (parentItem) | 186 | if (parentItem) |
186 | { | 187 | { |
187 | AttachItem*temp = lastChild(parentItem); | 188 | AttachItem*temp = lastChild(parentItem); |
188 | if (temp) curItem = temp; | 189 | if (temp) curItem = temp; |
189 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 190 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
190 | attachments->setRootIsDecorated(true); | 191 | attachments->setRootIsDecorated(true); |
191 | curItem = parentItem; | 192 | curItem = parentItem; |
192 | } | 193 | } |
193 | else | 194 | else |
194 | { | 195 | { |
195 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 196 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
196 | } | 197 | } |
197 | } | 198 | } |
198 | } | 199 | } |
199 | 200 | ||
200 | 201 | ||
201 | void ViewMail::slotShowHtml( bool state ) | 202 | void ViewMail::slotShowHtml( bool state ) |
202 | { | 203 | { |
203 | m_showHtml = state; | 204 | m_showHtml = state; |
204 | setText(); | 205 | setText(); |
205 | } | 206 | } |
206 | 207 | ||
207 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 208 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
208 | { | 209 | { |
209 | if (!item ) | 210 | if (!item ) |
210 | return; | 211 | return; |
211 | 212 | ||
212 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 213 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
213 | { | 214 | { |
214 | setText(); | 215 | setText(); |
215 | return; | 216 | return; |
216 | } | 217 | } |
217 | QPopupMenu *menu = new QPopupMenu(); | 218 | QPopupMenu *menu = new QPopupMenu(); |
218 | int ret=0; | 219 | int ret=0; |
219 | 220 | ||
220 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 221 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
221 | { | 222 | { |
222 | menu->insertItem( i18n( "Show Text" ), 1 ); | 223 | menu->insertItem( i18n( "Show Text" ), 1 ); |
223 | } | 224 | } |
224 | if (item->text(0).left(6)=="image/") { | 225 | if (item->text(0).left(6)=="image/") { |
225 | menu->insertItem(i18n("Display image preview"),2); | 226 | menu->insertItem(i18n("Display image preview"),2); |
226 | } | 227 | } |
227 | menu->insertItem( i18n( "Save Attachment" ), 0 ); | 228 | menu->insertItem( i18n( "Save Attachment" ), 0 ); |
228 | menu->insertSeparator(1); | 229 | menu->insertSeparator(1); |
229 | 230 | ||
230 | ret = menu->exec( point, 0 ); | 231 | ret = menu->exec( point, 0 ); |
231 | 232 | ||
232 | switch(ret) | 233 | switch(ret) |
233 | { | 234 | { |
234 | case 0: | 235 | case 0: |
235 | { | 236 | { |
236 | //MimeTypes types; | 237 | //MimeTypes types; |
237 | //types.insert( "all", "*" ); | 238 | //types.insert( "all", "*" ); |
238 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); | 239 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); |
239 | 240 | ||
240 | if( !str.isEmpty() ) | 241 | if( !str.isEmpty() ) |
241 | { | 242 | { |
242 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 243 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
243 | if (content) | 244 | if (content) |
244 | { | 245 | { |
245 | QFile output(str); | 246 | QFile output(str); |
246 | output.open(IO_WriteOnly); | 247 | output.open(IO_WriteOnly); |
247 | output.writeBlock(content->Content(),content->Length()); | 248 | output.writeBlock(content->Content(),content->Length()); |
248 | output.close(); | 249 | output.close(); |
249 | delete content; | 250 | delete content; |
250 | } | 251 | } |
251 | } | 252 | } |
252 | } | 253 | } |
253 | break ; | 254 | break ; |
254 | 255 | ||
255 | case 2: | 256 | case 2: |
256 | { | 257 | { |
257 | #ifdef DESKTOP_VERSION | 258 | #ifdef DESKTOP_VERSION |
258 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); | 259 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); |
259 | #else | 260 | #else |
260 | QString tmpfile = "/tmp/opiemail-image"; | 261 | QString tmpfile = "/tmp/opiemail-image"; |
261 | #endif | 262 | #endif |
262 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 263 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
263 | if (content) { | 264 | if (content) { |
264 | QFile output(tmpfile); | 265 | QFile output(tmpfile); |
265 | output.open(IO_WriteOnly); | 266 | output.open(IO_WriteOnly); |
266 | output.writeBlock(content->Content(),content->Length()); | 267 | output.writeBlock(content->Content(),content->Length()); |
267 | output.close(); | 268 | output.close(); |
268 | delete content; | 269 | delete content; |
269 | MailImageDlg iview(""); | 270 | MailImageDlg iview(""); |
270 | iview.setName(tmpfile); | 271 | iview.setName(tmpfile); |
271 | KApplication::execDialog(&iview); | 272 | KApplication::execDialog(&iview); |
272 | output.remove(); | 273 | output.remove(); |
273 | } | 274 | } |
274 | } | 275 | } |
275 | break; | 276 | break; |
276 | case 1: | 277 | case 1: |
277 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 278 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
278 | { | 279 | { |
279 | setText(); | 280 | setText(); |
280 | } | 281 | } |
281 | else | 282 | else |
282 | { | 283 | { |
283 | if ( m_recMail->Wrapper() != 0l ) | 284 | if ( m_recMail->Wrapper() != 0l ) |
284 | { // make sure that there is a wrapper , even after delete or simular actions | 285 | { // make sure that there is a wrapper , even after delete or simular actions |
285 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 286 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
286 | } | 287 | } |
287 | } | 288 | } |
288 | break; | 289 | break; |
289 | } | 290 | } |
290 | delete menu; | 291 | delete menu; |
291 | } | 292 | } |
292 | 293 | ||
293 | 294 | ||
294 | void ViewMail::setMail(const RecMailP&mail ) | 295 | void ViewMail::setMail(const RecMailP&mail ) |
295 | { | 296 | { |
296 | 297 | ||
297 | m_recMail = mail; | 298 | m_recMail = mail; |
298 | 299 | ||
299 | m_mail[0] = mail->getFrom(); | 300 | m_mail[0] = mail->getFrom(); |
300 | m_mail[1] = mail->getSubject(); | 301 | m_mail[1] = mail->getSubject(); |
301 | m_mail[3] = mail->getDate(); | 302 | m_mail[3] = mail->getDate(); |
302 | m_mail[4] = mail->Msgid(); | 303 | m_mail[4] = mail->Msgid(); |
303 | 304 | ||
304 | m_mail2[0] = mail->To(); | 305 | m_mail2[0] = mail->To(); |
305 | m_mail2[1] = mail->CC(); | 306 | m_mail2[1] = mail->CC(); |
306 | m_mail2[2] = mail->Bcc(); | 307 | m_mail2[2] = mail->Bcc(); |
307 | 308 | ||
308 | setText(); | 309 | setText(); |
309 | } | 310 | } |
310 | 311 | ||
311 | 312 | ||
312 | 313 | ||
313 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 314 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
314 | : ViewMailBase(parent, name, fl), _inLoop(false) | 315 | : ViewMailBase(parent, name, fl), _inLoop(false) |
315 | { | 316 | { |
316 | m_gotBody = false; | 317 | m_gotBody = false; |
317 | deleted = false; | 318 | deleted = false; |
318 | 319 | ||
319 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 320 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
320 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 321 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
321 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 322 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
322 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 323 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
323 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 324 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
324 | 325 | ||
325 | attachments->setEnabled(m_gotBody); | 326 | attachments->setEnabled(m_gotBody); |
326 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 327 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
327 | 328 | ||
328 | readConfig(); | 329 | readConfig(); |
329 | attachments->setSorting(-1); | 330 | attachments->setSorting(-1); |
330 | } | 331 | } |
331 | 332 | ||
332 | void ViewMail::readConfig() | 333 | void ViewMail::readConfig() |
333 | { | 334 | { |
334 | 335 | ||
335 | setFont ( KOPrefs::instance()->mReadFont ); | 336 | setFont ( KOPrefs::instance()->mReadFont ); |
336 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 337 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
337 | showHtml->setOn( m_showHtml ); | 338 | showHtml->setOn( m_showHtml ); |
338 | } | 339 | } |
339 | 340 | ||
340 | void ViewMail::setText() | 341 | void ViewMail::setText() |
341 | { | 342 | { |
342 | 343 | ||
343 | QString toString; | 344 | QString toString; |
344 | QString ccString; | 345 | QString ccString; |
345 | QString bccString; | 346 | QString bccString; |
346 | 347 | ||
347 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 348 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
348 | { | 349 | { |
349 | toString += (*it); | 350 | toString += (*it); |
350 | } | 351 | } |
351 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 352 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
352 | { | 353 | { |
353 | ccString += (*it); | 354 | ccString += (*it); |
354 | } | 355 | } |
355 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 356 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
356 | { | 357 | { |
357 | bccString += (*it); | 358 | bccString += (*it); |
358 | } | 359 | } |
359 | 360 | ||
360 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); | 361 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); |
361 | 362 | ||
362 | m_mailHtml = "<html><body>" | 363 | m_mailHtml = "<html><body>" |
363 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 364 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
364 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 365 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
365 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 366 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
366 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 367 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
367 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 368 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
368 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 369 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
369 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + | 370 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + |
370 | "</td></tr></table><font>"; | 371 | "</td></tr></table><font>"; |
371 | 372 | ||
372 | if ( !m_showHtml ) | 373 | if ( !m_showHtml ) |
373 | { | 374 | { |
374 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 375 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
375 | } | 376 | } |
376 | else | 377 | else |
377 | { | 378 | { |
378 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 379 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
379 | } | 380 | } |
380 | // remove later in favor of a real handling | 381 | // remove later in favor of a real handling |
381 | m_gotBody = true; | 382 | m_gotBody = true; |
382 | } | 383 | } |
383 | 384 | ||
384 | 385 | ||
385 | ViewMail::~ViewMail() | 386 | ViewMail::~ViewMail() |
386 | { | 387 | { |
387 | m_recMail->Wrapper()->cleanMimeCache(); | 388 | m_recMail->Wrapper()->cleanMimeCache(); |
388 | hide(); | 389 | hide(); |
389 | } | 390 | } |
390 | 391 | ||
391 | void ViewMail::hide() | 392 | void ViewMail::hide() |
392 | { | 393 | { |
393 | QWidget::hide(); | 394 | QWidget::hide(); |
394 | 395 | ||
395 | if (_inLoop) | 396 | if (_inLoop) |
396 | { | 397 | { |
397 | _inLoop = false; | 398 | _inLoop = false; |
398 | qApp->exit_loop(); | 399 | qApp->exit_loop(); |
399 | 400 | ||
400 | } | 401 | } |
401 | 402 | ||
402 | } | 403 | } |
403 | 404 | ||
404 | void ViewMail::exec() | 405 | void ViewMail::exec() |
405 | { | 406 | { |
406 | show(); | 407 | show(); |
407 | 408 | ||
408 | if (!_inLoop) | 409 | if (!_inLoop) |
409 | { | 410 | { |
410 | _inLoop = true; | 411 | _inLoop = true; |
411 | qApp->enter_loop(); | 412 | qApp->enter_loop(); |
412 | } | 413 | } |
413 | 414 | ||