author | harlekin <harlekin> | 2003-12-14 00:20:38 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-14 00:20:38 (UTC) |
commit | ff2b84787e454f8a11aaef7a4ce18941ac0d28fd (patch) (unidiff) | |
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 | 26 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 29 | ||||
-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, 64 insertions, 12 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 | |||
@@ -61,14 +61,14 @@ AbstractMail *IMAPviewItem::getWrapper() | |||
61 | void IMAPviewItem::refresh(QList<RecMail>&) | 61 | void IMAPviewItem::refresh(QList<RecMail>&) |
62 | { | 62 | { |
63 | QList<Folder> *folders = wrapper->listFolders(); | 63 | QList<Folder> *folders = wrapper->listFolders(); |
64 | 64 | ||
65 | QListViewItem *child = firstChild(); | 65 | QListViewItem *child = firstChild(); |
66 | while ( child ) { | 66 | while ( child ) { |
67 | QListViewItem *tmp = child; | 67 | QListViewItem *tmp = child; |
68 | child = child->nextSibling(); | 68 | child = child->nextSibling(); |
69 | delete tmp; | 69 | delete tmp; |
70 | } | 70 | } |
71 | 71 | ||
72 | Folder *it; | 72 | Folder *it; |
73 | for ( it = folders->first(); it; it = folders->next() ) { | 73 | for ( it = folders->first(); it; it = folders->next() ) { |
74 | (void) new IMAPfolderItem( it, this ); | 74 | (void) new IMAPfolderItem( it, this ); |
@@ -80,7 +80,7 @@ RecBody IMAPviewItem::fetchBody(const RecMail&) | |||
80 | return RecBody(); | 80 | return RecBody(); |
81 | } | 81 | } |
82 | 82 | ||
83 | IMAPfolderItem::~IMAPfolderItem() | 83 | IMAPfolderItem::~IMAPfolderItem() |
84 | { | 84 | { |
85 | delete folder; | 85 | delete folder; |
86 | } | 86 | } |
@@ -94,7 +94,7 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent ) | |||
94 | setText( 0, folder->getDisplayName() ); | 94 | setText( 0, folder->getDisplayName() ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 97 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
98 | { | 98 | { |
99 | imap->getWrapper()->listMessages( folder->getName(),target ); | 99 | imap->getWrapper()->listMessages( folder->getName(),target ); |
100 | } | 100 | } |
@@ -118,7 +118,7 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | |||
118 | void AccountView::populate( QList<Account> list ) | 118 | void AccountView::populate( QList<Account> list ) |
119 | { | 119 | { |
120 | clear(); | 120 | clear(); |
121 | 121 | ||
122 | Account *it; | 122 | Account *it; |
123 | for ( it = list.first(); it; it = list.next() ) { | 123 | for ( it = list.first(); it; it = list.next() ) { |
124 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 124 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
@@ -134,8 +134,10 @@ void AccountView::populate( QList<Account> list ) | |||
134 | } | 134 | } |
135 | 135 | ||
136 | void AccountView::refresh(QListViewItem *item) { | 136 | void AccountView::refresh(QListViewItem *item) { |
137 | |||
137 | qDebug("AccountView refresh..."); | 138 | qDebug("AccountView refresh..."); |
138 | if ( item ) { | 139 | if ( item ) { |
140 | m_currentItem = item; | ||
139 | QList<RecMail> headerlist; | 141 | QList<RecMail> headerlist; |
140 | headerlist.setAutoDelete(true); | 142 | headerlist.setAutoDelete(true); |
141 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 143 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
@@ -144,9 +146,19 @@ void AccountView::refresh(QListViewItem *item) { | |||
144 | } | 146 | } |
145 | } | 147 | } |
146 | 148 | ||
149 | void AccountView::refreshCurrent() | ||
150 | { | ||
151 | if ( !m_currentItem ) return; | ||
152 | QList<RecMail> headerlist; | ||
153 | headerlist.setAutoDelete(true); | ||
154 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | ||
155 | view->refresh(headerlist); | ||
156 | emit refreshMailview(&headerlist); | ||
157 | } | ||
158 | |||
147 | void AccountView::refreshAll() | 159 | void AccountView::refreshAll() |
148 | { | 160 | { |
149 | 161 | ||
150 | } | 162 | } |
151 | 163 | ||
152 | RecBody AccountView::fetchBody(const RecMail&aMail) | 164 | RecBody AccountView::fetchBody(const RecMail&aMail) |
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 | |||
@@ -77,9 +77,13 @@ public: | |||
77 | public slots: | 77 | public slots: |
78 | void refreshAll(); | 78 | void refreshAll(); |
79 | void refresh(QListViewItem *item); | 79 | void refresh(QListViewItem *item); |
80 | void refreshCurrent(); | ||
80 | 81 | ||
81 | signals: | 82 | signals: |
82 | void refreshMailview(QList<RecMail>*); | 83 | void refreshMailview(QList<RecMail>*); |
84 | |||
85 | private: | ||
86 | QListViewItem* m_currentItem; | ||
83 | }; | 87 | }; |
84 | 88 | ||
85 | #endif | 89 | #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 | |||
@@ -60,6 +60,11 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
60 | searchMails->addTo( toolBar ); | 60 | searchMails->addTo( toolBar ); |
61 | searchMails->addTo( mailMenu ); | 61 | searchMails->addTo( mailMenu ); |
62 | 62 | ||
63 | deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); | ||
64 | deleteMails->addTo( toolBar ); | ||
65 | deleteMails->addTo( mailMenu ); | ||
66 | connect( deleteMails, SIGNAL( activated() ), | ||
67 | SLOT( slotDeleteMail() ) ); | ||
63 | 68 | ||
64 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, | 69 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, |
65 | 0, 0, this ); | 70 | 0, 0, this ); |
@@ -98,7 +103,7 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
98 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 103 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
99 | SLOT( displayMail( QListViewItem * ) ) ); | 104 | SLOT( displayMail( QListViewItem * ) ) ); |
100 | 105 | ||
101 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 106 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
102 | 107 | ||
103 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 108 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
104 | } | 109 | } |
@@ -131,7 +136,7 @@ void MainWindow::slotAdjustColumns() | |||
131 | 136 | ||
132 | void MainWindow::slotShowFolders( bool show ) | 137 | void MainWindow::slotShowFolders( bool show ) |
133 | { | 138 | { |
134 | qDebug( "Show Folders" ); | 139 | qDebug( "Show Folders" ); |
135 | if ( show && folderView->isHidden() ) { | 140 | if ( show && folderView->isHidden() ) { |
136 | qDebug( "-> showing" ); | 141 | qDebug( "-> showing" ); |
137 | folderView->show(); | 142 | folderView->show(); |
@@ -153,6 +158,9 @@ void MainWindow::refreshMailView(QList<RecMail>*list) | |||
153 | } | 158 | } |
154 | void MainWindow::displayMail(QListViewItem*item) | 159 | void MainWindow::displayMail(QListViewItem*item) |
155 | { | 160 | { |
161 | |||
162 | m_currentItem = item; | ||
163 | |||
156 | if (!item) return; | 164 | if (!item) return; |
157 | RecMail mail = ((MailListViewItem*)item)->data(); | 165 | RecMail mail = ((MailListViewItem*)item)->data(); |
158 | RecBody body = folderView->fetchBody(mail); | 166 | RecBody body = folderView->fetchBody(mail); |
@@ -162,9 +170,24 @@ void MainWindow::displayMail(QListViewItem*item) | |||
162 | readMail.setMail( mail ); | 170 | readMail.setMail( mail ); |
163 | readMail.showMaximized(); | 171 | readMail.showMaximized(); |
164 | readMail.exec(); | 172 | readMail.exec(); |
165 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | 173 | |
174 | if ( readMail.deleted ) { | ||
175 | folderView->refreshCurrent(); | ||
176 | } else { | ||
177 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | ||
178 | } | ||
166 | } | 179 | } |
167 | 180 | ||
181 | void MainWindow::slotDeleteMail() | ||
182 | { | ||
183 | if (!m_currentItem) return; | ||
184 | RecMail mail = ((MailListViewItem*)m_currentItem)->data(); | ||
185 | mail.Wrapper()->deleteMail( mail ); | ||
186 | folderView->refreshCurrent(); | ||
187 | } | ||
188 | |||
189 | |||
190 | |||
168 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 191 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
169 | :QListViewItem(parent,item),mail_data() | 192 | :QListViewItem(parent,item),mail_data() |
170 | { | 193 | { |
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 | |||
@@ -26,16 +26,18 @@ protected slots: | |||
26 | virtual void slotShowFolders( bool show ); | 26 | virtual void slotShowFolders( bool show ); |
27 | virtual void refreshMailView(QList<RecMail>*); | 27 | virtual void refreshMailView(QList<RecMail>*); |
28 | virtual void displayMail(QListViewItem*); | 28 | virtual void displayMail(QListViewItem*); |
29 | virtual void slotDeleteMail(); | ||
29 | void slotAdjustLayout(); | 30 | void slotAdjustLayout(); |
30 | 31 | ||
31 | protected: | 32 | protected: |
32 | QToolBar *toolBar; | 33 | QToolBar *toolBar; |
33 | QMenuBar *menuBar; | 34 | QMenuBar *menuBar; |
34 | QPopupMenu *mailMenu, *settingsMenu; | 35 | QPopupMenu *mailMenu, *settingsMenu; |
35 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, | 36 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, |
36 | *editSettings, *editAccounts, *syncFolders; | 37 | *editSettings, *editAccounts, *syncFolders; |
37 | AccountView *folderView; | 38 | AccountView *folderView; |
38 | QListView *mailView; | 39 | QListView *mailView; |
40 | QListViewItem* m_currentItem; | ||
39 | QBoxLayout *layout; | 41 | QBoxLayout *layout; |
40 | }; | 42 | }; |
41 | 43 | ||
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 | |||
@@ -11,6 +11,7 @@ | |||
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 | 15 | ||
15 | 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) |
16 | : QListViewItem(parent,after),_partNum(num) | 17 | : QListViewItem(parent,after),_partNum(num) |
@@ -169,6 +170,7 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | |||
169 | 170 | ||
170 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 171 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
171 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 172 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
173 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); | ||
172 | 174 | ||
173 | attachments->setEnabled(m_gotBody); | 175 | attachments->setEnabled(m_gotBody); |
174 | 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 ) ) ); |
@@ -315,3 +317,9 @@ void ViewMail::slotForward() | |||
315 | composer.exec(); | 317 | composer.exec(); |
316 | } | 318 | } |
317 | 319 | ||
320 | void ViewMail::slotDeleteMail( ) | ||
321 | { | ||
322 | m_recMail.Wrapper()->deleteMail( m_recMail ); | ||
323 | hide(); | ||
324 | deleted = true; | ||
325 | } | ||
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 | |||
@@ -30,6 +30,7 @@ public: | |||
30 | void exec(); | 30 | void exec(); |
31 | void setMail( RecMail mail ); | 31 | void setMail( RecMail mail ); |
32 | void setBody( RecBody body ); | 32 | void setBody( RecBody body ); |
33 | bool deleted; | ||
33 | 34 | ||
34 | protected: | 35 | protected: |
35 | QString deHtml(const QString &string); | 36 | QString deHtml(const QString &string); |
@@ -39,6 +40,8 @@ protected slots: | |||
39 | void slotForward(); | 40 | void slotForward(); |
40 | void setText(); | 41 | void setText(); |
41 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); | 42 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); |
43 | void slotDeleteMail( ); | ||
44 | |||
42 | 45 | ||
43 | private: | 46 | private: |
44 | bool _inLoop; | 47 | bool _inLoop; |