summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 5206220..a89393c 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -151,96 +151,97 @@ void ViewMail::setBody(const RecBodyP&body )
151 filename=it.data(); 151 filename=it.data();
152 } 152 }
153 } 153 }
154 s = body->Parts()[i]->Size(); 154 s = body->Parts()[i]->Size();
155 w = 0; 155 w = 0;
156 while (s>1024) 156 while (s>1024)
157 { 157 {
158 s/=1024; 158 s/=1024;
159 ++w; 159 ++w;
160 if (w>=2) break; 160 if (w>=2) break;
161 } 161 }
162 switch(w) 162 switch(w)
163 { 163 {
164 case 1: 164 case 1:
165 q="k"; 165 q="k";
166 break; 166 break;
167 case 2: 167 case 2:
168 q="M"; 168 q="M";
169 break; 169 break;
170 default: 170 default:
171 q=""; 171 q="";
172 break; 172 break;
173 } 173 }
174 QTextOStream o(&fsize); 174 QTextOStream o(&fsize);
175 if (w>0) o.precision(2); else o.precision(0); 175 if (w>0) o.precision(2); else o.precision(0);
176 o.setf(QTextStream::fixed); 176 o.setf(QTextStream::fixed);
177 o << s << " " << q << "Byte"; 177 o << s << " " << q << "Byte";
178 desc = body->Parts()[i]->Description(); 178 desc = body->Parts()[i]->Description();
179 parentItem = searchParent(body->Parts()[i]->Positionlist()); 179 parentItem = searchParent(body->Parts()[i]->Positionlist());
180 if (parentItem) 180 if (parentItem)
181 { 181 {
182 AttachItem*temp = lastChild(parentItem); 182 AttachItem*temp = lastChild(parentItem);
183 if (temp) curItem = temp; 183 if (temp) curItem = temp;
184 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());
185 attachments->setRootIsDecorated(true); 185 attachments->setRootIsDecorated(true);
186 curItem = parentItem; 186 curItem = parentItem;
187 } 187 }
188 else 188 else
189 { 189 {
190 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());
191 } 191 }
192 } 192 }
193} 193}
194 194
195 195
196void ViewMail::slotShowHtml( bool state ) 196void ViewMail::slotShowHtml( bool state )
197{ 197{
198 m_showHtml = state; 198 m_showHtml = state;
199 m_lasttextpart=-2;
199 setMainText(); 200 setMainText();
200} 201}
201 202
202void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 203void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
203{ 204{
204 if (!item ) 205 if (!item )
205 return; 206 return;
206 207
207 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 208 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
208 { 209 {
209 setMainText(); 210 setMainText();
210 return; 211 return;
211 } 212 }
212 QPopupMenu *menu = new QPopupMenu(); 213 QPopupMenu *menu = new QPopupMenu();
213 int ret=0; 214 int ret=0;
214 215
215 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 216 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
216 { 217 {
217 menu->insertItem( tr( "Show Text" ), 1 ); 218 menu->insertItem( tr( "Show Text" ), 1 );
218 } 219 }
219 if (item->text(0).left(6)=="image/") { 220 if (item->text(0).left(6)=="image/") {
220 menu->insertItem(tr("Display image preview"),2); 221 menu->insertItem(tr("Display image preview"),2);
221 } 222 }
222 menu->insertItem( tr( "Save Attachment" ), 0 ); 223 menu->insertItem( tr( "Save Attachment" ), 0 );
223 menu->insertSeparator(1); 224 menu->insertSeparator(1);
224 225
225 ret = menu->exec( point, 0 ); 226 ret = menu->exec( point, 0 );
226 227
227 switch(ret) 228 switch(ret)
228 { 229 {
229 case 0: 230 case 0:
230 { 231 {
231 MimeTypes types; 232 MimeTypes types;
232 types.insert( "all", "*" ); 233 types.insert( "all", "*" );
233 QString str = OFileDialog::getSaveFileName( 1, 234 QString str = OFileDialog::getSaveFileName( 1,
234 "/", item->text( 2 ) , types, 0 ); 235 "/", item->text( 2 ) , types, 0 );
235 236
236 if( !str.isEmpty() ) 237 if( !str.isEmpty() )
237 { 238 {
238 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 239 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
239 if (content) 240 if (content)
240 { 241 {
241 QFile output(str); 242 QFile output(str);
242 output.open(IO_WriteOnly); 243 output.open(IO_WriteOnly);
243 output.writeBlock(content->Content(),content->Length()); 244 output.writeBlock(content->Content(),content->Length());
244 output.close(); 245 output.close();
245 delete content; 246 delete content;
246 } 247 }
@@ -286,96 +287,97 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
286 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment")); 287 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment"));
287 } 288 }
288 m_lastimagepart=(( AttachItem* )item )->Partnumber(); 289 m_lastimagepart=(( AttachItem* )item )->Partnumber();
289 } 290 }
290 break; 291 break;
291 case 1: 292 case 1:
292 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 293 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
293 { 294 {
294 setMainText(); 295 setMainText();
295 } 296 }
296 else 297 else
297 { 298 {
298 if ( m_recMail->Wrapper() != 0l ) 299 if ( m_recMail->Wrapper() != 0l )
299 { // make sure that there is a wrapper , even after delete or simular actions 300 { // make sure that there is a wrapper , even after delete or simular actions
300 if (m_lastdlg) { 301 if (m_lastdlg) {
301 m_lastdlg->hide(); 302 m_lastdlg->hide();
302 browser->show(); 303 browser->show();
303 } 304 }
304 if (m_lasttextpart == ( ( AttachItem* )item )->Partnumber() ) return; 305 if (m_lasttextpart == ( ( AttachItem* )item )->Partnumber() ) return;
305 m_lasttextpart = ( ( AttachItem* )item )->Partnumber(); 306 m_lasttextpart = ( ( AttachItem* )item )->Partnumber();
306 QString s = m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );; 307 QString s = m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );;
307 if (item->text(0).right(4)!="html") { 308 if (item->text(0).right(4)!="html") {
308 s = QString("<html><body>\n<font face=fixed>%1</font></body></html>").arg(QStyleSheet::convertFromPlainText(s)); 309 s = QString("<html><body>\n<font face=fixed>%1</font></body></html>").arg(QStyleSheet::convertFromPlainText(s));
309 } 310 }
310 browser->setText(s); 311 browser->setText(s);
311 } 312 }
312 } 313 }
313 break; 314 break;
314 } 315 }
315 delete menu; 316 delete menu;
316} 317}
317 318
318 319
319void ViewMail::setMail(const RecMailP&mail ) 320void ViewMail::setMail(const RecMailP&mail )
320{ 321{
321 322
322 m_recMail = mail; 323 m_recMail = mail;
323 324
324 m_mail[0] = mail->getFrom(); 325 m_mail[0] = mail->getFrom();
325 m_mail[1] = mail->getSubject(); 326 m_mail[1] = mail->getSubject();
326 m_mail[3] = mail->getStringDate(); 327 m_mail[3] = mail->getStringDate();
327 m_mail[4] = mail->Msgid(); 328 m_mail[4] = mail->Msgid();
328 329
329 m_mail2[0] = mail->To(); 330 m_mail2[0] = mail->To();
330 m_mail2[1] = mail->CC(); 331 m_mail2[1] = mail->CC();
331 m_mail2[2] = mail->Bcc(); 332 m_mail2[2] = mail->Bcc();
332 333
333 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); 334 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) );
335 m_lasttextpart=-2;
334 setMainText(); 336 setMainText();
335} 337}
336 338
337 339
338 340
339ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 341ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
340 : ViewMailBase(parent, name, fl), _inLoop(false) 342 : ViewMailBase(parent, name, fl), _inLoop(false)
341{ 343{
342 m_gotBody = false; 344 m_gotBody = false;
343 deleted = false; 345 deleted = false;
344 346
345 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 347 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
346 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 348 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
347 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 349 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
348 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 350 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
349 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) ); 351 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) );
350 352
351 attachments->setEnabled(m_gotBody); 353 attachments->setEnabled(m_gotBody);
352 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 354 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
353 m_lastdlg = 0; 355 m_lastdlg = 0;
354 _icounter = 0; 356 _icounter = 0;
355 m_lastimagepart = -1; 357 m_lastimagepart = -1;
356 m_lasttextpart = -2; 358 m_lasttextpart = -2;
357 359
358 readConfig(); 360 readConfig();
359 attachments->setSorting(-1); 361 attachments->setSorting(-1);
360} 362}
361 363
362void ViewMail::slotImageInline(bool how) 364void ViewMail::slotImageInline(bool how)
363{ 365{
364 Config cfg( "mail" ); 366 Config cfg( "mail" );
365 cfg.writeEntry( "showPicsInline", how); 367 cfg.writeEntry( "showPicsInline", how);
366 m_PicsInline = how; 368 m_PicsInline = how;
367 if (m_lastdlg&&!how) { 369 if (m_lastdlg&&!how) {
368 browser->show(); 370 browser->show();
369 m_lastdlg->hide(); 371 m_lastdlg->hide();
370 m_lastdlg->reparent(0,QPoint(0,0),false); 372 m_lastdlg->reparent(0,QPoint(0,0),false);
371 delete m_lastdlg; 373 delete m_lastdlg;
372 m_lastdlg = 0; 374 m_lastdlg = 0;
373 m_lastimagepart = -1; 375 m_lastimagepart = -1;
374 } 376 }
375} 377}
376 378
377void ViewMail::readConfig() 379void ViewMail::readConfig()
378{ 380{
379 Config cfg( "mail" ); 381 Config cfg( "mail" );
380 cfg.setGroup( "Settings" ); 382 cfg.setGroup( "Settings" );
381 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 383 m_showHtml = cfg.readBoolEntry( "showHtml", false );