summaryrefslogtreecommitdiffabout
path: root/kmicromail/viewmail.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kmicromail/viewmail.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-p1.zip
kdepimpi-p1.tar.gz
kdepimpi-p1.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kmicromail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/viewmail.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 685b4e4..c9dedb0 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -21,61 +21,64 @@
21 21
22#include <qdialog.h> 22#include <qdialog.h>
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26/* QT */ 26/* QT */
27#include <qtextbrowser.h> 27#include <q3textbrowser.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qtextstream.h> 29#include <q3textstream.h>
30#include <qaction.h> 30#include <qaction.h>
31#include <qpopupmenu.h> 31#include <q3popupmenu.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qlayout.h> 33#include <qlayout.h>
34//Added by qt3to4:
35#include <Q3ValueList>
36#include <Q3VBoxLayout>
34 37
35//using namespace Opie::Ui; 38//using namespace Opie::Ui;
36//using namespace Opie::Core; 39//using namespace Opie::Core;
37 40
38AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 41AttachItem::AttachItem(Q3ListView * parent,Q3ListViewItem *after, const QString&mime,const QString&desc,const QString&file,
39 const QString&fsize,int num,const QValueList<int>&path) 42 const QString&fsize,int num,const Q3ValueList<int>&path)
40 : QListViewItem(parent,after),_partNum(num) 43 : Q3ListViewItem(parent,after),_partNum(num)
41{ 44{
42 _path=path; 45 _path=path;
43 setText(0, mime); 46 setText(0, mime);
44 setText(1, desc); 47 setText(1, desc);
45 setText(2, file); 48 setText(2, file);
46 setText(3, fsize); 49 setText(3, fsize);
47} 50}
48 51
49AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 52AttachItem::AttachItem(Q3ListViewItem * parent,Q3ListViewItem *after, const QString&mime,const QString&desc,const QString&file,
50 const QString&fsize,int num,const QValueList<int>&path) 53 const QString&fsize,int num,const Q3ValueList<int>&path)
51 : QListViewItem(parent,after),_partNum(num) 54 : Q3ListViewItem(parent,after),_partNum(num)
52{ 55{
53 _path=path; 56 _path=path;
54 setText(0, mime); 57 setText(0, mime);
55 setText(1, desc); 58 setText(1, desc);
56 setText(2, file); 59 setText(2, file);
57 setText(3, fsize); 60 setText(3, fsize);
58} 61}
59 62
60bool AttachItem::isParentof(const QValueList<int>&path) 63bool AttachItem::isParentof(const Q3ValueList<int>&path)
61{ 64{
62 /* if not set, then no parent */ 65 /* if not set, then no parent */
63 if (path.count()==0||_path.count()==0) return false; 66 if (path.count()==0||_path.count()==0) return false;
64 /* the parent must have one digit less then a child */ 67 /* the parent must have one digit less then a child */
65 if (path.count()!=_path.count()+1) return false; 68 if (path.count()!=_path.count()+1) return false;
66 for (unsigned int i=0; i < _path.count();++i) 69 for (unsigned int i=0; i < _path.count();++i)
67 { 70 {
68 if (_path[i]!=path[i]) return false; 71 if (_path[i]!=path[i]) return false;
69 } 72 }
70 return true; 73 return true;
71} 74}
72 75
73AttachItem* ViewMail::searchParent(const QValueList<int>&path) 76AttachItem* ViewMail::searchParent(const Q3ValueList<int>&path)
74{ 77{
75 QListViewItemIterator it( attachments ); 78 Q3ListViewItemIterator it( attachments );
76 for ( ; it.current(); ++it ) 79 for ( ; it.current(); ++it )
77 { 80 {
78 AttachItem*ati = (AttachItem*)it.current(); 81 AttachItem*ati = (AttachItem*)it.current();
79 if (ati->isParentof(path)) return ati; 82 if (ati->isParentof(path)) return ati;
80 } 83 }
81 return 0; 84 return 0;
@@ -151,13 +154,13 @@ void ViewMail::setBody(const RecBodyP&body )
151 so I use this construct that the stream will re-constructed in each 154 so I use this construct that the stream will re-constructed in each
152 loop. To let it work, the textstream is packed into a own area of 155 loop. To let it work, the textstream is packed into a own area of
153 code is it will be destructed after finishing its small job. 156 code is it will be destructed after finishing its small job.
154 */ 157 */
155 QTextOStream o(&fsize); 158 QTextOStream o(&fsize);
156 if (w>0) o.precision(2); else o.precision(0); 159 if (w>0) o.precision(2); else o.precision(0);
157 o.setf(QTextStream::fixed); 160 o.setf(Q3TextStream::fixed);
158 o << s << " " << q << "Byte"; 161 o << s << " " << q << "Byte";
159 } 162 }
160 163
161 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); 164 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
162 QString filename = ""; 165 QString filename = "";
163 166
@@ -192,13 +195,13 @@ void ViewMail::setBody(const RecBodyP&body )
192 default: 195 default:
193 q=""; 196 q="";
194 break; 197 break;
195 } 198 }
196 QTextOStream o(&fsize); 199 QTextOStream o(&fsize);
197 if (w>0) o.precision(2); else o.precision(0); 200 if (w>0) o.precision(2); else o.precision(0);
198 o.setf(QTextStream::fixed); 201 o.setf(Q3TextStream::fixed);
199 o << s << " " << q << "Byte"; 202 o << s << " " << q << "Byte";
200 desc = body->Parts()[i]->Description(); 203 desc = body->Parts()[i]->Description();
201 parentItem = searchParent(body->Parts()[i]->Positionlist()); 204 parentItem = searchParent(body->Parts()[i]->Positionlist());
202 if (parentItem) 205 if (parentItem)
203 { 206 {
204 AttachItem*temp = lastChild(parentItem); 207 AttachItem*temp = lastChild(parentItem);
@@ -236,23 +239,23 @@ void ViewMail::slotViewSource()
236void ViewMail::slotShowHtml( bool state ) 239void ViewMail::slotShowHtml( bool state )
237{ 240{
238 m_showHtml = state; 241 m_showHtml = state;
239 setText(); 242 setText();
240} 243}
241 244
242void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 245void ViewMail::slotItemClicked( Q3ListViewItem * item , const QPoint & point, int )
243{ 246{
244 if (!item ) 247 if (!item )
245 return; 248 return;
246 249
247 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 250 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
248 { 251 {
249 setText(); 252 setText();
250 return; 253 return;
251 } 254 }
252 QPopupMenu *menu = new QPopupMenu(); 255 Q3PopupMenu *menu = new Q3PopupMenu();
253 int ret=0; 256 int ret=0;
254 257
255 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 258 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
256 { 259 {
257 menu->insertItem( i18n( "Show Text" ), 1 ); 260 menu->insertItem( i18n( "Show Text" ), 1 );
258 } 261 }
@@ -275,13 +278,13 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
275 if( !str.isEmpty() ) 278 if( !str.isEmpty() )
276 { 279 {
277 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 280 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
278 if (content) 281 if (content)
279 { 282 {
280 QFile output(str); 283 QFile output(str);
281 output.open(IO_WriteOnly); 284 output.open(QIODevice::WriteOnly);
282 output.writeBlock(content->Content(),content->Length()); 285 output.writeBlock(content->Content(),content->Length());
283 output.close(); 286 output.close();
284 delete content; 287 delete content;
285 } 288 }
286 } 289 }
287 } 290 }
@@ -294,13 +297,13 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
294#else 297#else
295 QString tmpfile = "/tmp/opiemail-image"; 298 QString tmpfile = "/tmp/opiemail-image";
296#endif 299#endif
297 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 300 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
298 if (content) { 301 if (content) {
299 QFile output(tmpfile); 302 QFile output(tmpfile);
300 output.open(IO_WriteOnly); 303 output.open(QIODevice::WriteOnly);
301 output.writeBlock(content->Content(),content->Length()); 304 output.writeBlock(content->Content(),content->Length());
302 output.close(); 305 output.close();
303 delete content; 306 delete content;
304 MailImageDlg iview(""); 307 MailImageDlg iview("");
305 iview.setName(tmpfile); 308 iview.setName(tmpfile);
306 KApplication::execDialog(&iview); 309 KApplication::execDialog(&iview);
@@ -349,13 +352,13 @@ void ViewMail::slotNextMail()
349 setCaption(i18n("Displaying next mail...please wait!")); 352 setCaption(i18n("Displaying next mail...please wait!"));
350 qApp->processEvents(); 353 qApp->processEvents();
351 emit showNextMail(this); 354 emit showNextMail(this);
352 nextMail->blockSignals( false ); 355 nextMail->blockSignals( false );
353} 356}
354 357
355ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 358ViewMail::ViewMail( QWidget *parent, const char *name, Qt::WFlags fl)
356 : ViewMailBase(parent, name, fl), _inLoop(false) 359 : ViewMailBase(parent, name, fl), _inLoop(false)
357{ 360{
358 m_gotBody = false; 361 m_gotBody = false;
359 deleted = false; 362 deleted = false;
360 sourceOn = false; 363 sourceOn = false;
361 readConfig(); 364 readConfig();
@@ -366,13 +369,13 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
366 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 369 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
367 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) ); 370 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) );
368 connect( viewSource, SIGNAL( activated() ), SLOT( slotViewSource() ) ); 371 connect( viewSource, SIGNAL( activated() ), SLOT( slotViewSource() ) );
369 connect( downloadMail, SIGNAL( activated() ), SIGNAL( signalDownloadMail() ) ); 372 connect( downloadMail, SIGNAL( activated() ), SIGNAL( signalDownloadMail() ) );
370 373
371 attachments->setEnabled(m_gotBody); 374 attachments->setEnabled(m_gotBody);
372 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 375 connect( attachments, SIGNAL( clicked(Q3ListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(Q3ListViewItem*,const QPoint&, int) ) );
373 376
374 attachments->setSorting(-1); 377 attachments->setSorting(-1);
375} 378}
376 379
377void ViewMail::readConfig() 380void ViewMail::readConfig()
378{ 381{
@@ -554,16 +557,16 @@ void ViewMail::slotDeleteMail( )
554 //m_recMail->Wrapper()->deleteMail( m_recMail ); 557 //m_recMail->Wrapper()->deleteMail( m_recMail );
555 //hide(); 558 //hide();
556 deleted = true; 559 deleted = true;
557 } 560 }
558} 561}
559 562
560MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) 563MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, Qt::WFlags f)
561 : QDialog(parent,name,modal) 564 : QDialog(parent,name,modal)
562{ 565{
563 QVBoxLayout*dlglayout = new QVBoxLayout(this); 566 Q3VBoxLayout*dlglayout = new Q3VBoxLayout(this);
564 dlglayout->setSpacing(2); 567 dlglayout->setSpacing(2);
565 dlglayout->setMargin(1); 568 dlglayout->setMargin(1);
566 //m_imageview = new Opie::MM::OImageScrollView(this); 569 //m_imageview = new Opie::MM::OImageScrollView(this);
567 //dlglayout->addWidget(m_imageview); 570 //dlglayout->addWidget(m_imageview);
568} 571}
569 572