author | zautrix <zautrix> | 2004-10-30 15:56:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-30 15:56:24 (UTC) |
commit | c8662dc632987a317386b923e24acb9507859528 (patch) (unidiff) | |
tree | 97ca9b266d075c3c0f2689769829c453f8118cd8 /kmicromail/viewmail.cpp | |
parent | 632b43950f1ac2980c281eb8901d797deb0ba971 (diff) | |
download | kdepimpi-c8662dc632987a317386b923e24acb9507859528.zip kdepimpi-c8662dc632987a317386b923e24acb9507859528.tar.gz kdepimpi-c8662dc632987a317386b923e24acb9507859528.tar.bz2 |
ompi desktop compile hack
-rw-r--r-- | kmicromail/viewmail.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 0b4c322..f1e0225 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -1,533 +1,536 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | |||
3 | |||
4 | |||
5 | #include <kfiledialog.h> | ||
6 | #include "koprefs.h" | ||
7 | #include <klocale.h> | ||
8 | #include <kglobal.h> | ||
9 | #include <kapplication.h> | ||
10 | |||
11 | #ifdef MINIKDE_KDIALOG_H | ||
12 | #undef MINIKDE_KDIALOG_H | ||
13 | #endif | ||
14 | |||
2 | #include "composemail.h" | 15 | #include "composemail.h" |
3 | #include "viewmail.h" | 16 | #include "viewmail.h" |
4 | 17 | ||
5 | #include <libmailwrapper/settings.h> | 18 | #include <libmailwrapper/settings.h> |
6 | #include <libmailwrapper/abstractmail.h> | 19 | #include <libmailwrapper/abstractmail.h> |
7 | #include <libmailwrapper/mailtypes.h> | 20 | #include <libmailwrapper/mailtypes.h> |
8 | #include <kapplication.h> | ||
9 | |||
10 | /* OPIE */ | ||
11 | //#include <opie2/odebug.h> | ||
12 | //#include <opie2/ofiledialog.h> | ||
13 | //#include <opie2/oimagescrollview.h> | ||
14 | 21 | ||
15 | #include <kfiledialog.h> | 22 | #include <qdialog.h> |
16 | #include <kdialog.h> | ||
17 | 23 | ||
18 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
19 | 25 | ||
20 | /* QT */ | 26 | /* QT */ |
21 | #include <qtextbrowser.h> | 27 | #include <qtextbrowser.h> |
22 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
23 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
24 | #include <qaction.h> | 30 | #include <qaction.h> |
25 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
26 | #include <qfile.h> | 32 | #include <qfile.h> |
27 | #include <qlayout.h> | 33 | #include <qlayout.h> |
28 | #include "koprefs.h" | ||
29 | #include <klocale.h> | ||
30 | #include <kglobal.h> | ||
31 | 34 | ||
32 | //using namespace Opie::Ui; | 35 | //using namespace Opie::Ui; |
33 | //using namespace Opie::Core; | 36 | //using namespace Opie::Core; |
34 | 37 | ||
35 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 38 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
36 | const QString&fsize,int num,const QValueList<int>&path) | 39 | const QString&fsize,int num,const QValueList<int>&path) |
37 | : QListViewItem(parent,after),_partNum(num) | 40 | : QListViewItem(parent,after),_partNum(num) |
38 | { | 41 | { |
39 | _path=path; | 42 | _path=path; |
40 | setText(0, mime); | 43 | setText(0, mime); |
41 | setText(1, desc); | 44 | setText(1, desc); |
42 | setText(2, file); | 45 | setText(2, file); |
43 | setText(3, fsize); | 46 | setText(3, fsize); |
44 | } | 47 | } |
45 | 48 | ||
46 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 49 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
47 | const QString&fsize,int num,const QValueList<int>&path) | 50 | const QString&fsize,int num,const QValueList<int>&path) |
48 | : QListViewItem(parent,after),_partNum(num) | 51 | : QListViewItem(parent,after),_partNum(num) |
49 | { | 52 | { |
50 | _path=path; | 53 | _path=path; |
51 | setText(0, mime); | 54 | setText(0, mime); |
52 | setText(1, desc); | 55 | setText(1, desc); |
53 | setText(2, file); | 56 | setText(2, file); |
54 | setText(3, fsize); | 57 | setText(3, fsize); |
55 | } | 58 | } |
56 | 59 | ||
57 | bool AttachItem::isParentof(const QValueList<int>&path) | 60 | bool AttachItem::isParentof(const QValueList<int>&path) |
58 | { | 61 | { |
59 | /* if not set, then no parent */ | 62 | /* if not set, then no parent */ |
60 | if (path.count()==0||_path.count()==0) return false; | 63 | if (path.count()==0||_path.count()==0) return false; |
61 | /* the parent must have one digit less then a child */ | 64 | /* the parent must have one digit less then a child */ |
62 | if (path.count()!=_path.count()+1) return false; | 65 | if (path.count()!=_path.count()+1) return false; |
63 | for (unsigned int i=0; i < _path.count();++i) | 66 | for (unsigned int i=0; i < _path.count();++i) |
64 | { | 67 | { |
65 | if (_path[i]!=path[i]) return false; | 68 | if (_path[i]!=path[i]) return false; |
66 | } | 69 | } |
67 | return true; | 70 | return true; |
68 | } | 71 | } |
69 | 72 | ||
70 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 73 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
71 | { | 74 | { |
72 | QListViewItemIterator it( attachments ); | 75 | QListViewItemIterator it( attachments ); |
73 | for ( ; it.current(); ++it ) | 76 | for ( ; it.current(); ++it ) |
74 | { | 77 | { |
75 | AttachItem*ati = (AttachItem*)it.current(); | 78 | AttachItem*ati = (AttachItem*)it.current(); |
76 | if (ati->isParentof(path)) return ati; | 79 | if (ati->isParentof(path)) return ati; |
77 | } | 80 | } |
78 | return 0; | 81 | return 0; |
79 | } | 82 | } |
80 | 83 | ||
81 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 84 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
82 | { | 85 | { |
83 | if (!parent) return 0; | 86 | if (!parent) return 0; |
84 | AttachItem* item = (AttachItem*)parent->firstChild(); | 87 | AttachItem* item = (AttachItem*)parent->firstChild(); |
85 | if (!item) return item; | 88 | if (!item) return item; |
86 | AttachItem*temp=0; | 89 | AttachItem*temp=0; |
87 | while( (temp=(AttachItem*)item->nextSibling())) | 90 | while( (temp=(AttachItem*)item->nextSibling())) |
88 | { | 91 | { |
89 | item = temp; | 92 | item = temp; |
90 | } | 93 | } |
91 | return item; | 94 | return item; |
92 | } | 95 | } |
93 | 96 | ||
94 | void ViewMail::setBody(const RecBodyP&body ) | 97 | void ViewMail::setBody(const RecBodyP&body ) |
95 | { | 98 | { |
96 | 99 | ||
97 | m_body = body; | 100 | m_body = body; |
98 | m_mail[2] = body->Bodytext(); | 101 | m_mail[2] = body->Bodytext(); |
99 | attachbutton->setEnabled(body->Parts().count()>0); | 102 | attachbutton->setEnabled(body->Parts().count()>0); |
100 | attachments->setEnabled(body->Parts().count()>0); | 103 | attachments->setEnabled(body->Parts().count()>0); |
101 | if (body->Parts().count()==0) | 104 | if (body->Parts().count()==0) |
102 | { | 105 | { |
103 | return; | 106 | return; |
104 | } | 107 | } |
105 | AttachItem * curItem=0; | 108 | AttachItem * curItem=0; |
106 | AttachItem * parentItem = 0; | 109 | AttachItem * parentItem = 0; |
107 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 110 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
108 | QString desc,fsize; | 111 | QString desc,fsize; |
109 | double s = body->Description()->Size(); | 112 | double s = body->Description()->Size(); |
110 | int w; | 113 | int w; |
111 | w=0; | 114 | w=0; |
112 | 115 | ||
113 | while (s>1024) | 116 | while (s>1024) |
114 | { | 117 | { |
115 | s/=1024; | 118 | s/=1024; |
116 | ++w; | 119 | ++w; |
117 | if (w>=2) break; | 120 | if (w>=2) break; |
118 | } | 121 | } |
119 | 122 | ||
120 | QString q=""; | 123 | QString q=""; |
121 | switch(w) | 124 | switch(w) |
122 | { | 125 | { |
123 | case 1: | 126 | case 1: |
124 | q="k"; | 127 | q="k"; |
125 | break; | 128 | break; |
126 | case 2: | 129 | case 2: |
127 | q="M"; | 130 | q="M"; |
128 | break; | 131 | break; |
129 | default: | 132 | default: |
130 | break; | 133 | break; |
131 | } | 134 | } |
132 | 135 | ||
133 | { | 136 | { |
134 | /* I did not found a method to make a CONTENT reset on a QTextStream | 137 | /* I did not found a method to make a CONTENT reset on a QTextStream |
135 | so I use this construct that the stream will re-constructed in each | 138 | so I use this construct that the stream will re-constructed in each |
136 | loop. To let it work, the textstream is packed into a own area of | 139 | loop. To let it work, the textstream is packed into a own area of |
137 | code is it will be destructed after finishing its small job. | 140 | code is it will be destructed after finishing its small job. |
138 | */ | 141 | */ |
139 | QTextOStream o(&fsize); | 142 | QTextOStream o(&fsize); |
140 | if (w>0) o.precision(2); else o.precision(0); | 143 | if (w>0) o.precision(2); else o.precision(0); |
141 | o.setf(QTextStream::fixed); | 144 | o.setf(QTextStream::fixed); |
142 | o << s << " " << q << "Byte"; | 145 | o << s << " " << q << "Byte"; |
143 | } | 146 | } |
144 | 147 | ||
145 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 148 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
146 | QString filename = ""; | 149 | QString filename = ""; |
147 | 150 | ||
148 | for (unsigned int i = 0; i < body->Parts().count();++i) | 151 | for (unsigned int i = 0; i < body->Parts().count();++i) |
149 | { | 152 | { |
150 | filename = ""; | 153 | filename = ""; |
151 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 154 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
152 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 155 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
153 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 156 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
154 | { | 157 | { |
155 | if (it.key().lower()=="name") | 158 | if (it.key().lower()=="name") |
156 | { | 159 | { |
157 | filename=it.data(); | 160 | filename=it.data(); |
158 | } | 161 | } |
159 | } | 162 | } |
160 | s = body->Parts()[i]->Size(); | 163 | s = body->Parts()[i]->Size(); |
161 | w = 0; | 164 | w = 0; |
162 | while (s>1024) | 165 | while (s>1024) |
163 | { | 166 | { |
164 | s/=1024; | 167 | s/=1024; |
165 | ++w; | 168 | ++w; |
166 | if (w>=2) break; | 169 | if (w>=2) break; |
167 | } | 170 | } |
168 | switch(w) | 171 | switch(w) |
169 | { | 172 | { |
170 | case 1: | 173 | case 1: |
171 | q="k"; | 174 | q="k"; |
172 | break; | 175 | break; |
173 | case 2: | 176 | case 2: |
174 | q="M"; | 177 | q="M"; |
175 | break; | 178 | break; |
176 | default: | 179 | default: |
177 | q=""; | 180 | q=""; |
178 | break; | 181 | break; |
179 | } | 182 | } |
180 | QTextOStream o(&fsize); | 183 | QTextOStream o(&fsize); |
181 | if (w>0) o.precision(2); else o.precision(0); | 184 | if (w>0) o.precision(2); else o.precision(0); |
182 | o.setf(QTextStream::fixed); | 185 | o.setf(QTextStream::fixed); |
183 | o << s << " " << q << "Byte"; | 186 | o << s << " " << q << "Byte"; |
184 | desc = body->Parts()[i]->Description(); | 187 | desc = body->Parts()[i]->Description(); |
185 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 188 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
186 | if (parentItem) | 189 | if (parentItem) |
187 | { | 190 | { |
188 | AttachItem*temp = lastChild(parentItem); | 191 | AttachItem*temp = lastChild(parentItem); |
189 | if (temp) curItem = temp; | 192 | if (temp) curItem = temp; |
190 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 193 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
191 | attachments->setRootIsDecorated(true); | 194 | attachments->setRootIsDecorated(true); |
192 | curItem = parentItem; | 195 | curItem = parentItem; |
193 | } | 196 | } |
194 | else | 197 | else |
195 | { | 198 | { |
196 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 199 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
197 | } | 200 | } |
198 | } | 201 | } |
199 | } | 202 | } |
200 | 203 | ||
201 | 204 | ||
202 | void ViewMail::slotShowHtml( bool state ) | 205 | void ViewMail::slotShowHtml( bool state ) |
203 | { | 206 | { |
204 | m_showHtml = state; | 207 | m_showHtml = state; |
205 | setText(); | 208 | setText(); |
206 | } | 209 | } |
207 | 210 | ||
208 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 211 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
209 | { | 212 | { |
210 | if (!item ) | 213 | if (!item ) |
211 | return; | 214 | return; |
212 | 215 | ||
213 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 216 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
214 | { | 217 | { |
215 | setText(); | 218 | setText(); |
216 | return; | 219 | return; |
217 | } | 220 | } |
218 | QPopupMenu *menu = new QPopupMenu(); | 221 | QPopupMenu *menu = new QPopupMenu(); |
219 | int ret=0; | 222 | int ret=0; |
220 | 223 | ||
221 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 224 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
222 | { | 225 | { |
223 | menu->insertItem( i18n( "Show Text" ), 1 ); | 226 | menu->insertItem( i18n( "Show Text" ), 1 ); |
224 | } | 227 | } |
225 | if (item->text(0).left(6)=="image/") { | 228 | if (item->text(0).left(6)=="image/") { |
226 | menu->insertItem(i18n("Display image preview"),2); | 229 | menu->insertItem(i18n("Display image preview"),2); |
227 | } | 230 | } |
228 | menu->insertItem( i18n( "Save Attachment" ), 0 ); | 231 | menu->insertItem( i18n( "Save Attachment" ), 0 ); |
229 | menu->insertSeparator(1); | 232 | menu->insertSeparator(1); |
230 | 233 | ||
231 | ret = menu->exec( point, 0 ); | 234 | ret = menu->exec( point, 0 ); |
232 | 235 | ||
233 | switch(ret) | 236 | switch(ret) |
234 | { | 237 | { |
235 | case 0: | 238 | case 0: |
236 | { | 239 | { |
237 | //MimeTypes types; | 240 | //MimeTypes types; |
238 | //types.insert( "all", "*" ); | 241 | //types.insert( "all", "*" ); |
239 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); | 242 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); |
240 | 243 | ||
241 | if( !str.isEmpty() ) | 244 | if( !str.isEmpty() ) |
242 | { | 245 | { |
243 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 246 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
244 | if (content) | 247 | if (content) |
245 | { | 248 | { |
246 | QFile output(str); | 249 | QFile output(str); |
247 | output.open(IO_WriteOnly); | 250 | output.open(IO_WriteOnly); |
248 | output.writeBlock(content->Content(),content->Length()); | 251 | output.writeBlock(content->Content(),content->Length()); |
249 | output.close(); | 252 | output.close(); |
250 | delete content; | 253 | delete content; |
251 | } | 254 | } |
252 | } | 255 | } |
253 | } | 256 | } |
254 | break ; | 257 | break ; |
255 | 258 | ||
256 | case 2: | 259 | case 2: |
257 | { | 260 | { |
258 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
259 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); | 262 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); |
260 | #else | 263 | #else |
261 | QString tmpfile = "/tmp/opiemail-image"; | 264 | QString tmpfile = "/tmp/opiemail-image"; |
262 | #endif | 265 | #endif |
263 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 266 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
264 | if (content) { | 267 | if (content) { |
265 | QFile output(tmpfile); | 268 | QFile output(tmpfile); |
266 | output.open(IO_WriteOnly); | 269 | output.open(IO_WriteOnly); |
267 | output.writeBlock(content->Content(),content->Length()); | 270 | output.writeBlock(content->Content(),content->Length()); |
268 | output.close(); | 271 | output.close(); |
269 | delete content; | 272 | delete content; |
270 | MailImageDlg iview(""); | 273 | MailImageDlg iview(""); |
271 | iview.setName(tmpfile); | 274 | iview.setName(tmpfile); |
272 | KApplication::execDialog(&iview); | 275 | KApplication::execDialog(&iview); |
273 | output.remove(); | 276 | output.remove(); |
274 | } | 277 | } |
275 | } | 278 | } |
276 | break; | 279 | break; |
277 | case 1: | 280 | case 1: |
278 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 281 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
279 | { | 282 | { |
280 | setText(); | 283 | setText(); |
281 | } | 284 | } |
282 | else | 285 | else |
283 | { | 286 | { |
284 | if ( m_recMail->Wrapper() != 0l ) | 287 | if ( m_recMail->Wrapper() != 0l ) |
285 | { // make sure that there is a wrapper , even after delete or simular actions | 288 | { // make sure that there is a wrapper , even after delete or simular actions |
286 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 289 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
287 | } | 290 | } |
288 | } | 291 | } |
289 | break; | 292 | break; |
290 | } | 293 | } |
291 | delete menu; | 294 | delete menu; |
292 | } | 295 | } |
293 | 296 | ||
294 | 297 | ||
295 | void ViewMail::setMail(const RecMailP&mail ) | 298 | void ViewMail::setMail(const RecMailP&mail ) |
296 | { | 299 | { |
297 | 300 | ||
298 | m_recMail = mail; | 301 | m_recMail = mail; |
299 | 302 | ||
300 | m_mail[0] = mail->getFrom(); | 303 | m_mail[0] = mail->getFrom(); |
301 | m_mail[1] = mail->getSubject(); | 304 | m_mail[1] = mail->getSubject(); |
302 | m_mail[3] = mail->getDate(); | 305 | m_mail[3] = mail->getDate(); |
303 | m_mail[4] = mail->Msgid(); | 306 | m_mail[4] = mail->Msgid(); |
304 | 307 | ||
305 | m_mail2[0] = mail->To(); | 308 | m_mail2[0] = mail->To(); |
306 | m_mail2[1] = mail->CC(); | 309 | m_mail2[1] = mail->CC(); |
307 | m_mail2[2] = mail->Bcc(); | 310 | m_mail2[2] = mail->Bcc(); |
308 | 311 | ||
309 | setText(); | 312 | setText(); |
310 | } | 313 | } |
311 | 314 | ||
312 | 315 | ||
313 | 316 | ||
314 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 317 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
315 | : ViewMailBase(parent, name, fl), _inLoop(false) | 318 | : ViewMailBase(parent, name, fl), _inLoop(false) |
316 | { | 319 | { |
317 | m_gotBody = false; | 320 | m_gotBody = false; |
318 | deleted = false; | 321 | deleted = false; |
319 | 322 | ||
320 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 323 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
321 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 324 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
322 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 325 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
323 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 326 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
324 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 327 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
325 | 328 | ||
326 | attachments->setEnabled(m_gotBody); | 329 | attachments->setEnabled(m_gotBody); |
327 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 330 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
328 | 331 | ||
329 | readConfig(); | 332 | readConfig(); |
330 | attachments->setSorting(-1); | 333 | attachments->setSorting(-1); |
331 | } | 334 | } |
332 | 335 | ||
333 | void ViewMail::readConfig() | 336 | void ViewMail::readConfig() |
334 | { | 337 | { |
335 | 338 | ||
336 | setFont ( KOPrefs::instance()->mReadFont ); | 339 | setFont ( KOPrefs::instance()->mReadFont ); |
337 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 340 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
338 | showHtml->setOn( m_showHtml ); | 341 | showHtml->setOn( m_showHtml ); |
339 | } | 342 | } |
340 | 343 | ||
341 | void ViewMail::setText() | 344 | void ViewMail::setText() |
342 | { | 345 | { |
343 | 346 | ||
344 | QString toString; | 347 | QString toString; |
345 | QString ccString; | 348 | QString ccString; |
346 | QString bccString; | 349 | QString bccString; |
347 | 350 | ||
348 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 351 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
349 | { | 352 | { |
350 | toString += (*it); | 353 | toString += (*it); |
351 | } | 354 | } |
352 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 355 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
353 | { | 356 | { |
354 | ccString += (*it); | 357 | ccString += (*it); |
355 | } | 358 | } |
356 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 359 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
357 | { | 360 | { |
358 | bccString += (*it); | 361 | bccString += (*it); |
359 | } | 362 | } |
360 | 363 | ||
361 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); | 364 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); |
362 | 365 | ||
363 | m_mailHtml = "<html><body>" | 366 | m_mailHtml = "<html><body>" |
364 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 367 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
365 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 368 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
366 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 369 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
367 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 370 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
368 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 371 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
369 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 372 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
370 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + | 373 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + |
371 | "</td></tr></table><font>"; | 374 | "</td></tr></table><font>"; |
372 | 375 | ||
373 | if ( !m_showHtml ) | 376 | if ( !m_showHtml ) |
374 | { | 377 | { |
375 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 378 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
376 | } | 379 | } |
377 | else | 380 | else |
378 | { | 381 | { |
379 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 382 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
380 | } | 383 | } |
381 | // remove later in favor of a real handling | 384 | // remove later in favor of a real handling |
382 | m_gotBody = true; | 385 | m_gotBody = true; |
383 | } | 386 | } |
384 | 387 | ||
385 | 388 | ||
386 | ViewMail::~ViewMail() | 389 | ViewMail::~ViewMail() |
387 | { | 390 | { |
388 | m_recMail->Wrapper()->cleanMimeCache(); | 391 | m_recMail->Wrapper()->cleanMimeCache(); |
389 | hide(); | 392 | hide(); |
390 | } | 393 | } |
391 | 394 | ||
392 | void ViewMail::hide() | 395 | void ViewMail::hide() |
393 | { | 396 | { |
394 | QWidget::hide(); | 397 | QWidget::hide(); |
395 | 398 | ||
396 | if (_inLoop) | 399 | if (_inLoop) |
397 | { | 400 | { |
398 | _inLoop = false; | 401 | _inLoop = false; |
399 | qApp->exit_loop(); | 402 | qApp->exit_loop(); |
400 | 403 | ||
401 | } | 404 | } |
402 | 405 | ||
403 | } | 406 | } |
404 | 407 | ||
405 | void ViewMail::exec() | 408 | void ViewMail::exec() |
406 | { | 409 | { |
407 | show(); | 410 | show(); |
408 | 411 | ||
409 | if (!_inLoop) | 412 | if (!_inLoop) |
410 | { | 413 | { |
411 | _inLoop = true; | 414 | _inLoop = true; |
412 | qApp->enter_loop(); | 415 | qApp->enter_loop(); |
413 | } | 416 | } |
414 | 417 | ||
415 | } | 418 | } |
416 | 419 | ||
417 | QString ViewMail::deHtml(const QString &string) | 420 | QString ViewMail::deHtml(const QString &string) |
418 | { | 421 | { |
419 | QString string_ = string; | 422 | QString string_ = string; |
420 | string_.replace(QRegExp("&"), "&"); | 423 | string_.replace(QRegExp("&"), "&"); |
421 | string_.replace(QRegExp("<"), "<"); | 424 | string_.replace(QRegExp("<"), "<"); |
422 | string_.replace(QRegExp(">"), ">"); | 425 | string_.replace(QRegExp(">"), ">"); |
423 | string_.replace(QRegExp("\\n"), "<br>"); | 426 | string_.replace(QRegExp("\\n"), "<br>"); |
424 | return string_; | 427 | return string_; |
425 | } | 428 | } |
426 | 429 | ||
427 | void ViewMail::slotReply() | 430 | void ViewMail::slotReply() |
428 | { | 431 | { |
429 | if (!m_gotBody) | 432 | if (!m_gotBody) |
430 | { | 433 | { |
431 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); | 434 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); |
432 | return; | 435 | return; |
433 | } | 436 | } |
434 | 437 | ||
435 | QString rtext; | 438 | QString rtext; |
436 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 439 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
437 | .arg( m_mail[0] ) | 440 | .arg( m_mail[0] ) |
438 | .arg( m_mail[3] ); | 441 | .arg( m_mail[3] ); |
439 | 442 | ||
440 | QString text = m_mail[2]; | 443 | QString text = m_mail[2]; |
441 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 444 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
442 | QStringList::Iterator it; | 445 | QStringList::Iterator it; |
443 | for (it = lines.begin(); it != lines.end(); it++) | 446 | for (it = lines.begin(); it != lines.end(); it++) |
444 | { | 447 | { |
445 | rtext += "> " + *it + "\n"; | 448 | rtext += "> " + *it + "\n"; |
446 | } | 449 | } |
447 | rtext += "\n"; | 450 | rtext += "\n"; |
448 | 451 | ||
449 | QString prefix; | 452 | QString prefix; |
450 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 453 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
451 | else prefix = "Re: "; // no i18n on purpose | 454 | else prefix = "Re: "; // no i18n on purpose |
452 | 455 | ||
453 | Settings *settings = new Settings(); | 456 | Settings *settings = new Settings(); |
454 | ComposeMail composer( settings ,this, 0, true); | 457 | ComposeMail composer( settings ,this, 0, true); |
455 | if (m_recMail->Replyto().isEmpty()) { | 458 | if (m_recMail->Replyto().isEmpty()) { |
456 | composer.setTo( m_recMail->getFrom()); | 459 | composer.setTo( m_recMail->getFrom()); |
457 | } else { | 460 | } else { |
458 | composer.setTo( m_recMail->Replyto()); | 461 | composer.setTo( m_recMail->Replyto()); |
459 | } | 462 | } |
460 | composer.setSubject( prefix + m_mail[1] ); | 463 | composer.setSubject( prefix + m_mail[1] ); |
461 | composer.setMessage( rtext ); | 464 | composer.setMessage( rtext ); |
462 | composer.setInReplyTo(m_recMail->Msgid()); | 465 | composer.setInReplyTo(m_recMail->Msgid()); |
463 | 466 | ||
464 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 467 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
465 | { | 468 | { |
466 | m_recMail->Wrapper()->answeredMail(m_recMail); | 469 | m_recMail->Wrapper()->answeredMail(m_recMail); |
467 | } | 470 | } |
468 | } | 471 | } |
469 | 472 | ||
470 | void ViewMail::slotForward() | 473 | void ViewMail::slotForward() |
471 | { | 474 | { |
472 | if (!m_gotBody) | 475 | if (!m_gotBody) |
473 | { | 476 | { |
474 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); | 477 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); |
475 | return; | 478 | return; |
476 | } | 479 | } |
477 | 480 | ||
478 | QString ftext; | 481 | QString ftext; |
479 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 482 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
480 | .arg( m_mail[0] ); | 483 | .arg( m_mail[0] ); |
481 | if (!m_mail[3].isNull()) | 484 | if (!m_mail[3].isNull()) |
482 | ftext += QString("Date: %1\n") | 485 | ftext += QString("Date: %1\n") |
483 | .arg( m_mail[3] ); | 486 | .arg( m_mail[3] ); |
484 | if (!m_mail[0].isNull()) | 487 | if (!m_mail[0].isNull()) |
485 | ftext += QString("From: %1\n") | 488 | ftext += QString("From: %1\n") |
486 | .arg( m_mail[0] ); | 489 | .arg( m_mail[0] ); |
487 | if (!m_mail[1].isNull()) | 490 | if (!m_mail[1].isNull()) |
488 | ftext += QString("Subject: %1\n") | 491 | ftext += QString("Subject: %1\n") |
489 | .arg( m_mail[1] ); | 492 | .arg( m_mail[1] ); |
490 | 493 | ||
491 | ftext += QString("\n%1\n") | 494 | ftext += QString("\n%1\n") |
492 | .arg( m_mail[2]); | 495 | .arg( m_mail[2]); |
493 | 496 | ||
494 | ftext += QString("----- End forwarded message -----\n"); | 497 | ftext += QString("----- End forwarded message -----\n"); |
495 | 498 | ||
496 | Settings *settings = new Settings(); | 499 | Settings *settings = new Settings(); |
497 | ComposeMail composer( settings ,this, 0, true); | 500 | ComposeMail composer( settings ,this, 0, true); |
498 | composer.setSubject( "Fwd: " + m_mail[1] ); | 501 | composer.setSubject( "Fwd: " + m_mail[1] ); |
499 | composer.setMessage( ftext ); | 502 | composer.setMessage( ftext ); |
500 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) | 503 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) |
501 | { | 504 | { |
502 | } | 505 | } |
503 | } | 506 | } |
504 | 507 | ||
505 | void ViewMail::slotDeleteMail( ) | 508 | void ViewMail::slotDeleteMail( ) |
506 | { | 509 | { |
507 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 510 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
508 | { | 511 | { |
509 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 512 | m_recMail->Wrapper()->deleteMail( m_recMail ); |
510 | hide(); | 513 | hide(); |
511 | deleted = true; | 514 | deleted = true; |
512 | } | 515 | } |
513 | } | 516 | } |
514 | 517 | ||
515 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | 518 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |
516 | : KDialog(parent,name,modal) | 519 | : QDialog(parent,name,modal) |
517 | { | 520 | { |
518 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 521 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
519 | dlglayout->setSpacing(2); | 522 | dlglayout->setSpacing(2); |
520 | dlglayout->setMargin(1); | 523 | dlglayout->setMargin(1); |
521 | //m_imageview = new Opie::MM::OImageScrollView(this); | 524 | //m_imageview = new Opie::MM::OImageScrollView(this); |
522 | //dlglayout->addWidget(m_imageview); | 525 | //dlglayout->addWidget(m_imageview); |
523 | } | 526 | } |
524 | 527 | ||
525 | MailImageDlg::~MailImageDlg() | 528 | MailImageDlg::~MailImageDlg() |
526 | { | 529 | { |
527 | } | 530 | } |
528 | 531 | ||
529 | void MailImageDlg::setName(const QString&fname) | 532 | void MailImageDlg::setName(const QString&fname) |
530 | { | 533 | { |
531 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); | 534 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); |
532 | // m_imageview->setImage(fname); | 535 | // m_imageview->setImage(fname); |
533 | } | 536 | } |