author | harlekin <harlekin> | 2003-12-14 00:20:38 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-14 00:20:38 (UTC) |
commit | ff2b84787e454f8a11aaef7a4ce18941ac0d28fd (patch) (side-by-side diff) | |
tree | 44bf51f9a3935542cdcfa5dafcc212e4f01ee8ce | |
parent | b0a71314013a3367767526b68928a7168b4ad460 (diff) | |
download | opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.zip opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.tar.gz opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.tar.bz2 |
deleting of mails working
-rw-r--r-- | noncore/net/mail/accountview.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 23 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 3 |
6 files changed, 53 insertions, 1 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 1069b9f..ac4f0e0 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -133,18 +133,30 @@ void AccountView::populate( QList<Account> list ) } } void AccountView::refresh(QListViewItem *item) { + qDebug("AccountView refresh..."); if ( item ) { + m_currentItem = item; QList<RecMail> headerlist; headerlist.setAutoDelete(true); AccountViewItem *view = static_cast<AccountViewItem *>(item); view->refresh(headerlist); emit refreshMailview(&headerlist); } } +void AccountView::refreshCurrent() +{ + if ( !m_currentItem ) return; + QList<RecMail> headerlist; + headerlist.setAutoDelete(true); + AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); + view->refresh(headerlist); + emit refreshMailview(&headerlist); +} + void AccountView::refreshAll() { } diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 83d49af..cdc87ce 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h @@ -76,10 +76,14 @@ public: public slots: void refreshAll(); void refresh(QListViewItem *item); + void refreshCurrent(); signals: void refreshMailview(QList<RecMail>*); + +private: + QListViewItem* m_currentItem; }; #endif diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 8ef7ddd..c410829 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -59,8 +59,13 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 0, 0, this ); searchMails->addTo( toolBar ); searchMails->addTo( mailMenu ); + deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); + deleteMails->addTo( toolBar ); + deleteMails->addTo( mailMenu ); + connect( deleteMails, SIGNAL( activated() ), + SLOT( slotDeleteMail() ) ); editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 0, 0, this ); editSettings->addTo( settingsMenu ); @@ -152,8 +157,11 @@ void MainWindow::refreshMailView(QList<RecMail>*list) } } void MainWindow::displayMail(QListViewItem*item) { + + m_currentItem = item; + if (!item) return; RecMail mail = ((MailListViewItem*)item)->data(); RecBody body = folderView->fetchBody(mail); @@ -161,10 +169,25 @@ void MainWindow::displayMail(QListViewItem*item) readMail.setBody( body ); readMail.setMail( mail ); readMail.showMaximized(); readMail.exec(); + + if ( readMail.deleted ) { + folderView->refreshCurrent(); + } else { ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); } +} + +void MainWindow::slotDeleteMail() +{ + if (!m_currentItem) return; + RecMail mail = ((MailListViewItem*)m_currentItem)->data(); + mail.Wrapper()->deleteMail( mail ); + folderView->refreshCurrent(); +} + + MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) :QListViewItem(parent,item),mail_data() { diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 6c1cda0..8641510 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h @@ -25,18 +25,20 @@ public slots: protected slots: virtual void slotShowFolders( bool show ); virtual void refreshMailView(QList<RecMail>*); virtual void displayMail(QListViewItem*); + virtual void slotDeleteMail(); void slotAdjustLayout(); protected: QToolBar *toolBar; QMenuBar *menuBar; QPopupMenu *mailMenu, *settingsMenu; - QAction *composeMail, *sendQueued, *showFolders, *searchMails, + QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, *editSettings, *editAccounts, *syncFolders; AccountView *folderView; QListView *mailView; + QListViewItem* m_currentItem; QBoxLayout *layout; }; #endif diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 42707e3..163ffb7 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp @@ -10,8 +10,9 @@ #include "settings.h" #include "composemail.h" #include "viewmail.h" #include "abstractmail.h" +#include "accountview.h" AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) : QListViewItem(parent,after),_partNum(num) { @@ -168,8 +169,9 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) m_gotBody = false; connect(reply, SIGNAL(activated()), SLOT(slotReply())); connect(forward, SIGNAL(activated()), SLOT(slotForward())); + connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); attachments->setEnabled(m_gotBody); connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); @@ -314,4 +316,10 @@ void ViewMail::slotForward() composer.showMaximized(); composer.exec(); } +void ViewMail::slotDeleteMail( ) +{ + m_recMail.Wrapper()->deleteMail( m_recMail ); + hide(); + deleted = true; +} diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index bc12da1..765464c 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h @@ -29,8 +29,9 @@ public: void hide(); void exec(); void setMail( RecMail mail ); void setBody( RecBody body ); + bool deleted; protected: QString deHtml(const QString &string); @@ -38,8 +39,10 @@ protected slots: void slotReply(); void slotForward(); void setText(); void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); + void slotDeleteMail( ); + private: bool _inLoop; QString m_mailHtml; |