summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-12-14 02:03:25 (UTC)
committer harlekin <harlekin>2003-12-14 02:03:25 (UTC)
commit568f23df5f4d5b1835c3b89ad54eeb6fc53157e6 (patch) (unidiff)
tree944c4745d4cdb642e873e480b45479d5116ea33a
parent154e03927d2b97f3f76f807fe104ac9d74035215 (diff)
downloadopie-568f23df5f4d5b1835c3b89ad54eeb6fc53157e6.zip
opie-568f23df5f4d5b1835c3b89ad54eeb6fc53157e6.tar.gz
opie-568f23df5f4d5b1835c3b89ad54eeb6fc53157e6.tar.bz2
check back before deleting a mail
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp7
-rw-r--r--noncore/net/mail/viewmail.cpp10
2 files changed, 11 insertions, 6 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 391b55e..e466d9b 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,217 +1,220 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qvbox.h> 2#include <qvbox.h>
3#include <qheader.h> 3#include <qheader.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qmessagebox.h>
6 7
7#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
8#include <qpe/resource.h> 9#include <qpe/resource.h>
9 10
10#include "defines.h" 11#include "defines.h"
11#include "mainwindow.h" 12#include "mainwindow.h"
12#include "viewmail.h" 13#include "viewmail.h"
13#include "mailtypes.h" 14#include "mailtypes.h"
14#include "mailistviewitem.h" 15#include "mailistviewitem.h"
15 16
16MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 17MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
17 : QMainWindow( parent, name, flags ) 18 : QMainWindow( parent, name, flags )
18{ 19{
19 setCaption( tr( "Mail" ) ); 20 setCaption( tr( "Mail" ) );
20 setToolBarsMovable( false ); 21 setToolBarsMovable( false );
21 22
22 toolBar = new QToolBar( this ); 23 toolBar = new QToolBar( this );
23 menuBar = new QMenuBar( toolBar ); 24 menuBar = new QMenuBar( toolBar );
24 mailMenu = new QPopupMenu( menuBar ); 25 mailMenu = new QPopupMenu( menuBar );
25 menuBar->insertItem( tr( "Mail" ), mailMenu ); 26 menuBar->insertItem( tr( "Mail" ), mailMenu );
26 settingsMenu = new QPopupMenu( menuBar ); 27 settingsMenu = new QPopupMenu( menuBar );
27 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 28 menuBar->insertItem( tr( "Settings" ), settingsMenu );
28 29
29 addToolBar( toolBar ); 30 addToolBar( toolBar );
30 toolBar->setHorizontalStretchable( true ); 31 toolBar->setHorizontalStretchable( true );
31 32
32 QLabel *spacer = new QLabel( toolBar ); 33 QLabel *spacer = new QLabel( toolBar );
33 spacer->setBackgroundMode( QWidget::PaletteButton ); 34 spacer->setBackgroundMode( QWidget::PaletteButton );
34 toolBar->setStretchableWidget( spacer ); 35 toolBar->setStretchableWidget( spacer );
35 36
36 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 37 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
37 0, 0, this ); 38 0, 0, this );
38 composeMail->addTo( toolBar ); 39 composeMail->addTo( toolBar );
39 composeMail->addTo( mailMenu ); 40 composeMail->addTo( mailMenu );
40 41
41 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 42 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
42 0, 0, this ); 43 0, 0, this );
43 sendQueued->addTo( toolBar ); 44 sendQueued->addTo( toolBar );
44 sendQueued->addTo( mailMenu ); 45 sendQueued->addTo( mailMenu );
45 46
46 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 47 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
47 0, 0, this ); 48 0, 0, this );
48 syncFolders->addTo( toolBar ); 49 syncFolders->addTo( toolBar );
49 syncFolders->addTo( mailMenu ); 50 syncFolders->addTo( mailMenu );
50 51
51 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 52 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
52 0, 0, this, 0, true ); 53 0, 0, this, 0, true );
53 showFolders->addTo( toolBar ); 54 showFolders->addTo( toolBar );
54 showFolders->addTo( mailMenu ); 55 showFolders->addTo( mailMenu );
55 connect(showFolders, SIGNAL( toggled( bool ) ), 56 connect(showFolders, SIGNAL( toggled( bool ) ),
56 SLOT( slotShowFolders( bool ) ) ); 57 SLOT( slotShowFolders( bool ) ) );
57 58
58 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 59 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS,
59 0, 0, this ); 60 0, 0, this );
60 searchMails->addTo( toolBar ); 61 searchMails->addTo( toolBar );
61 searchMails->addTo( mailMenu ); 62 searchMails->addTo( mailMenu );
62 63
63 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); 64 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
64 deleteMails->addTo( toolBar ); 65 deleteMails->addTo( toolBar );
65 deleteMails->addTo( mailMenu ); 66 deleteMails->addTo( mailMenu );
66 connect( deleteMails, SIGNAL( activated() ), 67 connect( deleteMails, SIGNAL( activated() ),
67 SLOT( slotDeleteMail() ) ); 68 SLOT( slotDeleteMail() ) );
68 69
69 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 70 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
70 0, 0, this ); 71 0, 0, this );
71 editSettings->addTo( settingsMenu ); 72 editSettings->addTo( settingsMenu );
72 73
73 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 74 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
74 0, 0, this ); 75 0, 0, this );
75 editAccounts->addTo( settingsMenu ); 76 editAccounts->addTo( settingsMenu );
76 77
77 QWidget *view = new QWidget( this ); 78 QWidget *view = new QWidget( this );
78 setCentralWidget( view ); 79 setCentralWidget( view );
79 80
80 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 81 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
81 82
82 folderView = new AccountView( view ); 83 folderView = new AccountView( view );
83 folderView->header()->hide(); 84 folderView->header()->hide();
84 folderView->setRootIsDecorated( false ); 85 folderView->setRootIsDecorated( false );
85 folderView->addColumn( tr( "Mailbox" ) ); 86 folderView->addColumn( tr( "Mailbox" ) );
86 folderView->hide(); 87 folderView->hide();
87 88
88 layout->addWidget( folderView ); 89 layout->addWidget( folderView );
89 90
90 mailView = new QListView( view ); 91 mailView = new QListView( view );
91 mailView->addColumn( tr( "" ) ); 92 mailView->addColumn( tr( "" ) );
92 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 93 mailView->addColumn( tr( "Subject" ),QListView::Manual );
93 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 94 mailView->addColumn( tr( "Sender" ),QListView::Manual );
94 mailView->addColumn( tr( "Date" )); 95 mailView->addColumn( tr( "Date" ));
95 mailView->setAllColumnsShowFocus(true); 96 mailView->setAllColumnsShowFocus(true);
96 mailView->setSorting(-1); 97 mailView->setSorting(-1);
97 98
98 layout->addWidget( mailView ); 99 layout->addWidget( mailView );
99 layout->setStretchFactor( folderView, 1 ); 100 layout->setStretchFactor( folderView, 1 );
100 layout->setStretchFactor( mailView, 2 ); 101 layout->setStretchFactor( mailView, 2 );
101 102
102 slotAdjustLayout(); 103 slotAdjustLayout();
103 104
104 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, 105 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
105 SLOT( displayMail( QListViewItem * ) ) ); 106 SLOT( displayMail( QListViewItem * ) ) );
106 107
107 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 108 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
108 109
109 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 110 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
110} 111}
111 112
112 113
113void MainWindow::slotAdjustLayout() { 114void MainWindow::slotAdjustLayout() {
114 115
115 QWidget *d = QApplication::desktop(); 116 QWidget *d = QApplication::desktop();
116 117
117 if ( d->width() < d->height() ) { 118 if ( d->width() < d->height() ) {
118 layout->setDirection( QBoxLayout::TopToBottom ); 119 layout->setDirection( QBoxLayout::TopToBottom );
119 } else { 120 } else {
120 layout->setDirection( QBoxLayout::LeftToRight ); 121 layout->setDirection( QBoxLayout::LeftToRight );
121 } 122 }
122 delete d; 123 delete d;
123} 124}
124 125
125void MainWindow::slotAdjustColumns() 126void MainWindow::slotAdjustColumns()
126{ 127{
127 bool hidden = folderView->isHidden(); 128 bool hidden = folderView->isHidden();
128 if ( hidden ) folderView->show(); 129 if ( hidden ) folderView->show();
129 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 130 folderView->setColumnWidth( 0, folderView->visibleWidth() );
130 if ( hidden ) folderView->hide(); 131 if ( hidden ) folderView->hide();
131 132
132 mailView->setColumnWidth( 0, 10 ); 133 mailView->setColumnWidth( 0, 10 );
133 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 134 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
134 mailView->setColumnWidth( 2, 80 ); 135 mailView->setColumnWidth( 2, 80 );
135 mailView->setColumnWidth( 3, 50 ); 136 mailView->setColumnWidth( 3, 50 );
136} 137}
137 138
138void MainWindow::slotShowFolders( bool show ) 139void MainWindow::slotShowFolders( bool show )
139{ 140{
140 qDebug( "Show Folders" ); 141 qDebug( "Show Folders" );
141 if ( show && folderView->isHidden() ) { 142 if ( show && folderView->isHidden() ) {
142 qDebug( "-> showing" ); 143 qDebug( "-> showing" );
143 folderView->show(); 144 folderView->show();
144 } else if ( !show && !folderView->isHidden() ) { 145 } else if ( !show && !folderView->isHidden() ) {
145 qDebug( "-> hiding" ); 146 qDebug( "-> hiding" );
146 folderView->hide(); 147 folderView->hide();
147 } 148 }
148} 149}
149 150
150void MainWindow::refreshMailView(QList<RecMail>*list) 151void MainWindow::refreshMailView(QList<RecMail>*list)
151{ 152{
152 MailListViewItem*item = 0; 153 MailListViewItem*item = 0;
153 mailView->clear(); 154 mailView->clear();
154 for (unsigned int i = 0; i < list->count();++i) { 155 for (unsigned int i = 0; i < list->count();++i) {
155 item = new MailListViewItem(mailView,item); 156 item = new MailListViewItem(mailView,item);
156 item->storeData(*(list->at(i))); 157 item->storeData(*(list->at(i)));
157 item->showEntry(); 158 item->showEntry();
158 } 159 }
159} 160}
160void MainWindow::displayMail(QListViewItem*item) 161void MainWindow::displayMail(QListViewItem*item)
161{ 162{
162 163
163 if (!item) return; 164 if (!item) return;
164 RecMail mail = ((MailListViewItem*)item)->data(); 165 RecMail mail = ((MailListViewItem*)item)->data();
165 RecBody body = folderView->fetchBody(mail); 166 RecBody body = folderView->fetchBody(mail);
166 167
167 ViewMail readMail( this ); 168 ViewMail readMail( this );
168 readMail.setBody( body ); 169 readMail.setBody( body );
169 readMail.setMail( mail ); 170 readMail.setMail( mail );
170 readMail.showMaximized(); 171 readMail.showMaximized();
171 readMail.exec(); 172 readMail.exec();
172 173
173 if ( readMail.deleted ) { 174 if ( readMail.deleted ) {
174 folderView->refreshCurrent(); 175 folderView->refreshCurrent();
175 } else { 176 } else {
176 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 177 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
177 } 178 }
178} 179}
179 180
180void MainWindow::slotDeleteMail() 181void MainWindow::slotDeleteMail()
181{ 182{
182 if (!mailView->currentItem()) return; 183 if (!mailView->currentItem()) return;
183 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 184 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
184 mail.Wrapper()->deleteMail( mail ); 185 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
185 folderView->refreshCurrent(); 186 mail.Wrapper()->deleteMail( mail );
187 folderView->refreshCurrent();
188 }
186} 189}
187 190
188 191
189 192
190MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 193MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
191 :QListViewItem(parent,item),mail_data() 194 :QListViewItem(parent,item),mail_data()
192{ 195{
193} 196}
194 197
195void MailListViewItem::showEntry() 198void MailListViewItem::showEntry()
196{ 199{
197 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 200 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
198 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 201 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
199 } else { 202 } else {
200 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); 203 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") );
201 } 204 }
202 setText(1,mail_data.getSubject()); 205 setText(1,mail_data.getSubject());
203 setText(2,mail_data.getFrom()); 206 setText(2,mail_data.getFrom());
204 setText(3,mail_data.getDate()); 207 setText(3,mail_data.getDate());
205} 208}
206 209
207void MailListViewItem::storeData(const RecMail&data) 210void MailListViewItem::storeData(const RecMail&data)
208{ 211{
209 mail_data = data; 212 mail_data = data;
210} 213}
211 214
212const RecMail& MailListViewItem::data()const 215const RecMail& MailListViewItem::data()const
213{ 216{
214 return mail_data; 217 return mail_data;
215} 218}
216 219
217 220
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 163ffb7..2415c82 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1,325 +1,327 @@
1#include <qtextbrowser.h> 1#include <qtextbrowser.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>?
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qaction.h> 4#include <qaction.h>
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qapplication.h> 6#include <qapplication.h>
7 7
8#include <opie/ofiledialog.h> 8#include <opie/ofiledialog.h>
9 9
10#include "settings.h" 10#include "settings.h"
11#include "composemail.h" 11#include "composemail.h"
12#include "viewmail.h" 12#include "viewmail.h"
13#include "abstractmail.h" 13#include "abstractmail.h"
14#include "accountview.h" 14#include "accountview.h"
15 15
16AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) 16AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num)
17 : QListViewItem(parent,after),_partNum(num) 17 : QListViewItem(parent,after),_partNum(num)
18{ 18{
19 setText(0, mime); 19 setText(0, mime);
20 setText(1, file); 20 setText(1, file);
21 setText(2, desc); 21 setText(2, desc);
22} 22}
23 23
24void ViewMail::setBody( RecBody body ) { 24void ViewMail::setBody( RecBody body ) {
25 25
26m_body = body; 26m_body = body;
27m_mail[2] = body.Bodytext(); 27m_mail[2] = body.Bodytext();
28attachbutton->setEnabled(body.Parts().count()>0); 28attachbutton->setEnabled(body.Parts().count()>0);
29attachments->setEnabled(body.Parts().count()>0); 29attachments->setEnabled(body.Parts().count()>0);
30if (body.Parts().count()==0) { 30if (body.Parts().count()==0) {
31 return; 31 return;
32} 32}
33AttachItem * curItem=0; 33AttachItem * curItem=0;
34QString type=body.Description().Type()+"/"+body.Description().Subtype(); 34QString type=body.Description().Type()+"/"+body.Description().Subtype();
35QString desc; 35QString desc;
36double s = body.Description().Size(); 36double s = body.Description().Size();
37int w; 37int w;
38w=0; 38w=0;
39 39
40while (s>1024) { 40while (s>1024) {
41 s/=1024; 41 s/=1024;
42 ++w; 42 ++w;
43 if (w>=2) break; 43 if (w>=2) break;
44} 44}
45 45
46QString q=""; 46QString q="";
47switch(w) { 47switch(w) {
48case 1: 48case 1:
49 q="k"; 49 q="k";
50 break; 50 break;
51case 2: 51case 2:
52 q="M"; 52 q="M";
53 break; 53 break;
54default: 54default:
55 break; 55 break;
56} 56}
57 57
58{ 58{
59 /* I did not found a method to make a CONTENT reset on a QTextStream 59 /* I did not found a method to make a CONTENT reset on a QTextStream
60 so I use this construct that the stream will re-constructed in each 60 so I use this construct that the stream will re-constructed in each
61 loop. To let it work, the textstream is packed into a own area of 61 loop. To let it work, the textstream is packed into a own area of
62 code is it will be destructed after finishing its small job. 62 code is it will be destructed after finishing its small job.
63 */ 63 */
64 QTextOStream o(&desc); 64 QTextOStream o(&desc);
65 if (w>0) o.precision(2); else o.precision(0); 65 if (w>0) o.precision(2); else o.precision(0);
66 o.setf(QTextStream::fixed); 66 o.setf(QTextStream::fixed);
67 o << s << " " << q << "Byte"; 67 o << s << " " << q << "Byte";
68} 68}
69 69
70curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); 70curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1);
71QString filename = ""; 71QString filename = "";
72for (unsigned int i = 0; i < body.Parts().count();++i) { 72for (unsigned int i = 0; i < body.Parts().count();++i) {
73 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); 73 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype();
74 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); 74 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin();
75 for (;it!=body.Parts()[i].Parameters().end();++it) { 75 for (;it!=body.Parts()[i].Parameters().end();++it) {
76 if (it.key().lower()=="name") { 76 if (it.key().lower()=="name") {
77 filename=it.data(); 77 filename=it.data();
78 } 78 }
79 } 79 }
80 s = body.Parts()[i].Size(); 80 s = body.Parts()[i].Size();
81 w = 0; 81 w = 0;
82 while (s>1024) { 82 while (s>1024) {
83 s/=1024; 83 s/=1024;
84 ++w; 84 ++w;
85 if (w>=2) break; 85 if (w>=2) break;
86 } 86 }
87 switch(w) { 87 switch(w) {
88 case 1: 88 case 1:
89 q="k"; 89 q="k";
90 break; 90 break;
91 case 2: 91 case 2:
92 q="M"; 92 q="M";
93 break; 93 break;
94 default: 94 default:
95 q=""; 95 q="";
96 break; 96 break;
97 } 97 }
98 QTextOStream o(&desc); 98 QTextOStream o(&desc);
99 if (w>0) o.precision(2); else o.precision(0); 99 if (w>0) o.precision(2); else o.precision(0);
100 o.setf(QTextStream::fixed); 100 o.setf(QTextStream::fixed);
101 o << s << " " << q << "Byte"; 101 o << s << " " << q << "Byte";
102 curItem=new AttachItem(attachments,curItem,type,filename,desc,i); 102 curItem=new AttachItem(attachments,curItem,type,filename,desc,i);
103} 103}
104} 104}
105 105
106void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { 106void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) {
107 if (!item ) 107 if (!item )
108 return; 108 return;
109 109
110 QPopupMenu *menu = new QPopupMenu(); 110 QPopupMenu *menu = new QPopupMenu();
111 int ret=0; 111 int ret=0;
112 112
113 if ( item->text( 0 ).left( 4 ) == "text" ) { 113 if ( item->text( 0 ).left( 4 ) == "text" ) {
114 menu->insertItem( tr( "Show Text" ), 1 ); 114 menu->insertItem( tr( "Show Text" ), 1 );
115 } 115 }
116 menu->insertItem( tr( "Save Attachment" ), 0 ); 116 menu->insertItem( tr( "Save Attachment" ), 0 );
117 menu->insertSeparator(1); 117 menu->insertSeparator(1);
118 118
119 ret = menu->exec( point, 0 ); 119 ret = menu->exec( point, 0 );
120 120
121 switch(ret) { 121 switch(ret) {
122 case 0: 122 case 0:
123 { MimeTypes types; 123 { MimeTypes types;
124 types.insert( "all", "*" ); 124 types.insert( "all", "*" );
125 QString str = OFileDialog::getSaveFileName( 1, 125 QString str = OFileDialog::getSaveFileName( 1,
126 "/", item->text( 1 ) , types, 0 ); 126 "/", item->text( 1 ) , types, 0 );
127 127
128 if( !str.isEmpty() ) { 128 if( !str.isEmpty() ) {
129 qDebug( "first we will need a MIME wrapper" ); 129 qDebug( "first we will need a MIME wrapper" );
130 } 130 }
131 } 131 }
132 break ; 132 break ;
133 133
134 case 1: 134 case 1:
135 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 135 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) {
136 setText(); 136 setText();
137 } else { 137 } else {
138 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions 138 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions
139 browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 139 browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
140 } 140 }
141 } 141 }
142 break; 142 break;
143 } 143 }
144 delete menu; 144 delete menu;
145} 145}
146 146
147 147
148void ViewMail::setMail( RecMail mail ) { 148void ViewMail::setMail( RecMail mail ) {
149 149
150m_recMail = mail; 150m_recMail = mail;
151 151
152m_mail[0] = mail.getFrom(); 152m_mail[0] = mail.getFrom();
153m_mail[1] = mail.getSubject(); 153m_mail[1] = mail.getSubject();
154m_mail[3] = mail.getDate(); 154m_mail[3] = mail.getDate();
155m_mail[4] = mail.Msgid(); 155m_mail[4] = mail.Msgid();
156 156
157m_mail2[0] = mail.To(); 157m_mail2[0] = mail.To();
158m_mail2[1] = mail.CC(); 158m_mail2[1] = mail.CC();
159m_mail2[2] = mail.Bcc(); 159m_mail2[2] = mail.Bcc();
160 160
161setText(); 161setText();
162} 162}
163 163
164 164
165 165
166ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 166ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
167 : ViewMailBase(parent, name, fl), _inLoop(false) 167 : ViewMailBase(parent, name, fl), _inLoop(false)
168{ 168{
169 m_gotBody = false; 169 m_gotBody = false;
170 170
171 connect(reply, SIGNAL(activated()), SLOT(slotReply())); 171 connect(reply, SIGNAL(activated()), SLOT(slotReply()));
172 connect(forward, SIGNAL(activated()), SLOT(slotForward())); 172 connect(forward, SIGNAL(activated()), SLOT(slotForward()));
173 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); 173 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) );
174 174
175 attachments->setEnabled(m_gotBody); 175 attachments->setEnabled(m_gotBody);
176 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); 176 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) );
177 177
178} 178}
179 179
180void ViewMail::setText() 180void ViewMail::setText()
181{ 181{
182 182
183 QString toString; 183 QString toString;
184 QString ccString; 184 QString ccString;
185 QString bccString; 185 QString bccString;
186 186
187 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { 187 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) {
188 toString += (*it); 188 toString += (*it);
189 } 189 }
190 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { 190 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) {
191 ccString += (*it); 191 ccString += (*it);
192 } 192 }
193 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { 193 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) {
194 bccString += (*it); 194 bccString += (*it);
195 } 195 }
196 196
197 setCaption( caption().arg( m_mail[0] ) ); 197 setCaption( caption().arg( m_mail[0] ) );
198 198
199 m_mailHtml = "<html><body>" 199 m_mailHtml = "<html><body>"
200 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 200 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
201 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 201 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
202 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 202 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
203 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 203 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
204 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 204 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
205 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 205 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
206 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 206 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
207 "</td></tr></table><font face=fixed>"; 207 "</td></tr></table><font face=fixed>";
208 208
209 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 209 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
210 // remove later in favor of a real handling 210 // remove later in favor of a real handling
211 m_gotBody = true; 211 m_gotBody = true;
212} 212}
213 213
214 214
215ViewMail::~ViewMail() 215ViewMail::~ViewMail()
216{ 216{
217 hide(); 217 hide();
218} 218}
219 219
220void ViewMail::hide() 220void ViewMail::hide()
221{ 221{
222 QWidget::hide(); 222 QWidget::hide();
223 223
224 if (_inLoop) { 224 if (_inLoop) {
225 _inLoop = false; 225 _inLoop = false;
226 qApp->exit_loop(); 226 qApp->exit_loop();
227 227
228 } 228 }
229 229
230} 230}
231 231
232void ViewMail::exec() 232void ViewMail::exec()
233{ 233{
234 show(); 234 show();
235 235
236 if (!_inLoop) { 236 if (!_inLoop) {
237 _inLoop = true; 237 _inLoop = true;
238 qApp->enter_loop(); 238 qApp->enter_loop();
239 } 239 }
240 240
241} 241}
242 242
243QString ViewMail::deHtml(const QString &string) 243QString ViewMail::deHtml(const QString &string)
244{ 244{
245 QString string_ = string; 245 QString string_ = string;
246 string_.replace(QRegExp("&"), "&amp;"); 246 string_.replace(QRegExp("&"), "&amp;");
247 string_.replace(QRegExp("<"), "&lt;"); 247 string_.replace(QRegExp("<"), "&lt;");
248 string_.replace(QRegExp(">"), "&gt;"); 248 string_.replace(QRegExp(">"), "&gt;");
249 string_.replace(QRegExp("\\n"), "<br>"); 249 string_.replace(QRegExp("\\n"), "<br>");
250 return string_; 250 return string_;
251} 251}
252 252
253void ViewMail::slotReply() 253void ViewMail::slotReply()
254{ 254{
255 if (!m_gotBody) { 255 if (!m_gotBody) {
256 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 256 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
257 return; 257 return;
258 } 258 }
259 259
260 QString rtext; 260 QString rtext;
261 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 261 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
262 .arg( m_mail[1] ) 262 .arg( m_mail[1] )
263 .arg( m_mail[3] ); 263 .arg( m_mail[3] );
264 264
265 QString text = m_mail[2]; 265 QString text = m_mail[2];
266 QStringList lines = QStringList::split(QRegExp("\\n"), text); 266 QStringList lines = QStringList::split(QRegExp("\\n"), text);
267 QStringList::Iterator it; 267 QStringList::Iterator it;
268 for (it = lines.begin(); it != lines.end(); it++) { 268 for (it = lines.begin(); it != lines.end(); it++) {
269 rtext += "> " + *it + "\n"; 269 rtext += "> " + *it + "\n";
270 } 270 }
271 rtext += "\n"; 271 rtext += "\n";
272 272
273 QString prefix; 273 QString prefix;
274 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; 274 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = "";
275 else prefix = "Re: "; // no i18n on purpose 275 else prefix = "Re: "; // no i18n on purpose
276 276
277 Settings *settings = new Settings(); 277 Settings *settings = new Settings();
278 ComposeMail composer( settings ,this, 0, true); 278 ComposeMail composer( settings ,this, 0, true);
279 composer.setTo( m_mail[0] ); 279 composer.setTo( m_mail[0] );
280 composer.setSubject( "Re: " + m_mail[1] ); 280 composer.setSubject( "Re: " + m_mail[1] );
281 composer.setMessage( rtext ); 281 composer.setMessage( rtext );
282 composer.showMaximized(); 282 composer.showMaximized();
283 composer.exec(); 283 composer.exec();
284 284
285} 285}
286 286
287void ViewMail::slotForward() 287void ViewMail::slotForward()
288{ 288{
289 if (!m_gotBody) { 289 if (!m_gotBody) {
290 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 290 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
291 return; 291 return;
292 } 292 }
293 293
294 QString ftext; 294 QString ftext;
295 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 295 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
296 .arg( m_mail[0] ); 296 .arg( m_mail[0] );
297 if (!m_mail[3].isNull()) 297 if (!m_mail[3].isNull())
298 ftext += QString("Date: %1\n") 298 ftext += QString("Date: %1\n")
299 .arg( m_mail[3] ); 299 .arg( m_mail[3] );
300 if (!m_mail[0].isNull()) 300 if (!m_mail[0].isNull())
301 ftext += QString("From: %1\n") 301 ftext += QString("From: %1\n")
302 .arg( m_mail[0] ); 302 .arg( m_mail[0] );
303 if (!m_mail[1].isNull()) 303 if (!m_mail[1].isNull())
304 ftext += QString("Subject: %1\n") 304 ftext += QString("Subject: %1\n")
305 .arg( m_mail[1] ); 305 .arg( m_mail[1] );
306 306
307 ftext += QString("\n%1\n") 307 ftext += QString("\n%1\n")
308 .arg( m_mail[2]); 308 .arg( m_mail[2]);
309 309
310 ftext += QString("----- End forwarded message -----\n"); 310 ftext += QString("----- End forwarded message -----\n");
311 311
312 Settings *settings = new Settings(); 312 Settings *settings = new Settings();
313 ComposeMail composer( settings ,this, 0, true); 313 ComposeMail composer( settings ,this, 0, true);
314 composer.setSubject( "Fwd: " + m_mail[1] ); 314 composer.setSubject( "Fwd: " + m_mail[1] );
315 composer.setMessage( ftext ); 315 composer.setMessage( ftext );
316 composer.showMaximized(); 316 composer.showMaximized();
317 composer.exec(); 317 composer.exec();
318} 318}
319 319
320void ViewMail::slotDeleteMail( ) 320void ViewMail::slotDeleteMail( )
321{ 321{
322 m_recMail.Wrapper()->deleteMail( m_recMail ); 322 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 ) {
323 hide(); 323 m_recMail.Wrapper()->deleteMail( m_recMail );
324 deleted = true; 324 hide();
325 deleted = true;
326 }
325} 327}