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