summaryrefslogtreecommitdiff
Unidiff
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,69 +1,70 @@
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,
@@ -120,98 +121,100 @@ void MainWindow::slotAdjustLayout() {
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,66 +1,66 @@
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);
@@ -258,68 +258,70 @@ void ViewMail::slotReply()
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}