author | harlekin <harlekin> | 2003-12-14 02:03:25 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-14 02:03:25 (UTC) |
commit | 568f23df5f4d5b1835c3b89ad54eeb6fc53157e6 (patch) (unidiff) | |
tree | 944c4745d4cdb642e873e480b45479d5116ea33a | |
parent | 154e03927d2b97f3f76f807fe104ac9d74035215 (diff) | |
download | opie-568f23df5f4d5b1835c3b89ad54eeb6fc53157e6.zip opie-568f23df5f4d5b1835c3b89ad54eeb6fc53157e6.tar.gz opie-568f23df5f4d5b1835c3b89ad54eeb6fc53157e6.tar.bz2 |
check back before deleting a mail
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 10 |
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,53 +1,54 @@ | |||
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 | ||
16 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 17 | MainWindow::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 ); |
@@ -136,82 +137,84 @@ void MainWindow::slotAdjustColumns() | |||
136 | } | 137 | } |
137 | 138 | ||
138 | void MainWindow::slotShowFolders( bool show ) | 139 | void 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 | ||
150 | void MainWindow::refreshMailView(QList<RecMail>*list) | 151 | void 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 | } |
160 | void MainWindow::displayMail(QListViewItem*item) | 161 | void 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 | ||
180 | void MainWindow::slotDeleteMail() | 181 | void 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 | ||
190 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 193 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
191 | :QListViewItem(parent,item),mail_data() | 194 | :QListViewItem(parent,item),mail_data() |
192 | { | 195 | { |
193 | } | 196 | } |
194 | 197 | ||
195 | void MailListViewItem::showEntry() | 198 | void 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 | ||
207 | void MailListViewItem::storeData(const RecMail&data) | 210 | void MailListViewItem::storeData(const RecMail&data) |
208 | { | 211 | { |
209 | mail_data = data; | 212 | mail_data = data; |
210 | } | 213 | } |
211 | 214 | ||
212 | const RecMail& MailListViewItem::data()const | 215 | const 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,50 +1,50 @@ | |||
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 | ||
16 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) | 16 | AttachItem::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 | ||
24 | void ViewMail::setBody( RecBody body ) { | 24 | void ViewMail::setBody( RecBody body ) { |
25 | 25 | ||
26 | m_body = body; | 26 | m_body = body; |
27 | m_mail[2] = body.Bodytext(); | 27 | m_mail[2] = body.Bodytext(); |
28 | attachbutton->setEnabled(body.Parts().count()>0); | 28 | attachbutton->setEnabled(body.Parts().count()>0); |
29 | attachments->setEnabled(body.Parts().count()>0); | 29 | attachments->setEnabled(body.Parts().count()>0); |
30 | if (body.Parts().count()==0) { | 30 | if (body.Parts().count()==0) { |
31 | return; | 31 | return; |
32 | } | 32 | } |
33 | AttachItem * curItem=0; | 33 | AttachItem * curItem=0; |
34 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 34 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
35 | QString desc; | 35 | QString desc; |
36 | double s = body.Description().Size(); | 36 | double s = body.Description().Size(); |
37 | int w; | 37 | int w; |
38 | w=0; | 38 | w=0; |
39 | 39 | ||
40 | while (s>1024) { | 40 | while (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 | ||
46 | QString q=""; | 46 | QString q=""; |
47 | switch(w) { | 47 | switch(w) { |
48 | case 1: | 48 | case 1: |
49 | q="k"; | 49 | q="k"; |
50 | break; | 50 | break; |
@@ -274,52 +274,54 @@ void ViewMail::slotReply() | |||
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 | ||
287 | void ViewMail::slotForward() | 287 | void 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 | ||
320 | void ViewMail::slotDeleteMail( ) | 320 | void 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 | } |