author | alwin <alwin> | 2004-01-08 14:04:54 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-08 14:04:54 (UTC) |
commit | ab6a32266c8fb625e782c601c9729af7f98904f6 (patch) (unidiff) | |
tree | 1457c421109359bdaa50082f2640d33ac4d74cc2 | |
parent | b85bc4484bcc0a53557b4759c3e9e58dc9059138 (diff) | |
download | opie-ab6a32266c8fb625e782c601c9729af7f98904f6.zip opie-ab6a32266c8fb625e782c601c9729af7f98904f6.tar.gz opie-ab6a32266c8fb625e782c601c9729af7f98904f6.tar.bz2 |
- store single message to another folder implemented
- cleaned code in mainwindow and opiemail.cpp
-rw-r--r-- | noncore/net/mail/accountview.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 30 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 1 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.cpp | 65 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 151 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 119 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.h | 8 |
13 files changed, 263 insertions, 140 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index b7de7b9..9f4f358 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -874,2 +874,3 @@ QPopupMenu * MBOXfolderItem::getContextMenu() | |||
874 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 874 | m->insertItem(QObject::tr("Delete folder",contextName),1); |
875 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | ||
875 | } | 876 | } |
@@ -878,2 +879,9 @@ QPopupMenu * MBOXfolderItem::getContextMenu() | |||
878 | 879 | ||
880 | void MBOXfolderItem::downloadMails() | ||
881 | { | ||
882 | AccountView*bl = mbox->accountView(); | ||
883 | if (!bl) return; | ||
884 | bl->downloadMails(folder,mbox->getWrapper()); | ||
885 | } | ||
886 | |||
879 | void MBOXfolderItem::contextMenuSelected(int which) | 887 | void MBOXfolderItem::contextMenuSelected(int which) |
@@ -887,2 +895,5 @@ void MBOXfolderItem::contextMenuSelected(int which) | |||
887 | break; | 895 | break; |
896 | case 2: | ||
897 | downloadMails(); | ||
898 | break; | ||
888 | default: | 899 | default: |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index df916c1..d9b5558 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -155,2 +155,3 @@ public: | |||
155 | protected: | 155 | protected: |
156 | void downloadMails(); | ||
156 | virtual void deleteFolder(); | 157 | virtual void deleteFolder(); |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 4b4c728..0280803 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -125 +125,14 @@ void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abs | |||
125 | } | 125 | } |
126 | |||
127 | void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
128 | { | ||
129 | encodedString*st = 0; | ||
130 | st = fetchRawBody(mail); | ||
131 | if (st) { | ||
132 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | ||
133 | delete st; | ||
134 | } | ||
135 | if (moveit) { | ||
136 | deleteMail(mail); | ||
137 | } | ||
138 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 8debaae..f93bab4 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -38,2 +38,3 @@ public: | |||
38 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 38 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
39 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
39 | 40 | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 98634a3..4b633ea 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1058 +1058,31 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst | |||
1058 | } | 1058 | } |
1059 | |||
1060 | void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
1061 | { | ||
1062 | if (targetWrapper != this) { | ||
1063 | qDebug("Using generic"); | ||
1064 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | ||
1065 | return; | ||
1066 | } | ||
1067 | mailimap_set *set = 0; | ||
1068 | login(); | ||
1069 | if (!m_imap) { | ||
1070 | return; | ||
1071 | } | ||
1072 | int err = selectMbox(mail.getMbox()); | ||
1073 | if ( err != MAILIMAP_NO_ERROR ) { | ||
1074 | return; | ||
1075 | } | ||
1076 | set = mailimap_set_new_single(mail.getNumber()); | ||
1077 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | ||
1078 | mailimap_set_free( set ); | ||
1079 | if ( err != MAILIMAP_NO_ERROR ) { | ||
1080 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | ||
1081 | Global::statusMessage(error_msg); | ||
1082 | qDebug(error_msg); | ||
1083 | return; | ||
1084 | } | ||
1085 | if (moveit) { | ||
1086 | deleteMail(mail); | ||
1087 | } | ||
1088 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 99986c2..c10f86a 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -34,2 +34,3 @@ public: | |||
34 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 34 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
35 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
35 | 36 | ||
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 1abd2e8..90e1e46 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro | |||
@@ -25,2 +25,3 @@ SOURCES = main.cpp \ | |||
25 | viewmailbase.cpp \ | 25 | viewmailbase.cpp \ |
26 | mailistviewitem.cpp \ | ||
26 | settingsdialog.cpp \ | 27 | settingsdialog.cpp \ |
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp new file mode 100644 index 0000000..f224dc3 --- a/dev/null +++ b/noncore/net/mail/mailistviewitem.cpp | |||
@@ -0,0 +1,65 @@ | |||
1 | #include "mailistviewitem.h" | ||
2 | #include <qtextstream.h> | ||
3 | #include <qpe/resource.h> | ||
4 | |||
5 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | ||
6 | :QListViewItem(parent,item),mail_data() | ||
7 | { | ||
8 | } | ||
9 | |||
10 | void MailListViewItem::showEntry() | ||
11 | { | ||
12 | if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { | ||
13 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); | ||
14 | } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { | ||
15 | /* I think it looks nicer if there are not such a log of icons but only on mails | ||
16 | replied or new - Alwin*/ | ||
17 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); | ||
18 | } else { | ||
19 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); | ||
20 | } | ||
21 | double s = mail_data.Msgsize(); | ||
22 | int w; | ||
23 | w=0; | ||
24 | |||
25 | while (s>1024) { | ||
26 | s/=1024; | ||
27 | ++w; | ||
28 | if (w>=2) break; | ||
29 | } | ||
30 | |||
31 | QString q=""; | ||
32 | QString fsize=""; | ||
33 | switch(w) { | ||
34 | case 1: | ||
35 | q="k"; | ||
36 | break; | ||
37 | case 2: | ||
38 | q="M"; | ||
39 | break; | ||
40 | default: | ||
41 | break; | ||
42 | } | ||
43 | |||
44 | { | ||
45 | QTextOStream o(&fsize); | ||
46 | if (w>0) o.precision(2); else o.precision(0); | ||
47 | o.setf(QTextStream::fixed); | ||
48 | o << s << " " << q << "Byte"; | ||
49 | } | ||
50 | |||
51 | setText(1,mail_data.getSubject()); | ||
52 | setText(2,mail_data.getFrom()); | ||
53 | setText(3,fsize); | ||
54 | setText(4,mail_data.getDate()); | ||
55 | } | ||
56 | |||
57 | void MailListViewItem::storeData(const RecMail&data) | ||
58 | { | ||
59 | mail_data = data; | ||
60 | } | ||
61 | |||
62 | const RecMail& MailListViewItem::data()const | ||
63 | { | ||
64 | return mail_data; | ||
65 | } | ||
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h index 271f616..3b352a2 100644 --- a/noncore/net/mail/mailistviewitem.h +++ b/noncore/net/mail/mailistviewitem.h | |||
@@ -6,3 +6,2 @@ | |||
6 | 6 | ||
7 | |||
8 | class MailListViewItem:public QListViewItem | 7 | class MailListViewItem:public QListViewItem |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index e16f853..c38392c 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -6,3 +6,2 @@ | |||
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qtextstream.h> | ||
8 | 7 | ||
@@ -11,8 +10,4 @@ | |||
11 | 10 | ||
12 | |||
13 | #include "defines.h" | 11 | #include "defines.h" |
14 | #include "mainwindow.h" | 12 | #include "mainwindow.h" |
15 | #include "viewmail.h" | ||
16 | #include <libmailwrapper/mailtypes.h> | ||
17 | #include "mailistviewitem.h" | ||
18 | 13 | ||
@@ -129,2 +124,12 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
129 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 124 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
125 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | ||
126 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | ||
127 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | ||
128 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | ||
129 | // Added by Stefan Eilers to allow starting by addressbook.. | ||
130 | // copied from old mail2 | ||
131 | #if !defined(QT_NO_COP) | ||
132 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), | ||
133 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | ||
134 | #endif | ||
130 | 135 | ||
@@ -137,2 +142,7 @@ MainWindow::~MainWindow() | |||
137 | 142 | ||
143 | void MainWindow::appMessage(const QCString &, const QByteArray &) | ||
144 | { | ||
145 | qDebug("appMessage not reached"); | ||
146 | } | ||
147 | |||
138 | void MainWindow::slotAdjustLayout() { | 148 | void MainWindow::slotAdjustLayout() { |
@@ -166,30 +176,15 @@ void MainWindow::slotEditSettings() | |||
166 | 176 | ||
167 | void MainWindow::slotShowFolders( bool show ) | 177 | void MainWindow::slotShowFolders( bool ) |
168 | { | 178 | { |
169 | qDebug( "Show Folders" ); | 179 | qDebug( "slotShowFolders not reached" ); |
170 | if ( show && folderView->isHidden() ) { | ||
171 | qDebug( "-> showing" ); | ||
172 | folderView->show(); | ||
173 | } else if ( !show && !folderView->isHidden() ) { | ||
174 | qDebug( "-> hiding" ); | ||
175 | folderView->hide(); | ||
176 | } | ||
177 | } | 180 | } |
178 | 181 | ||
179 | void MainWindow::refreshMailView(QList<RecMail>*list) | 182 | void MainWindow::refreshMailView(QList<RecMail>*) |
180 | { | 183 | { |
181 | MailListViewItem*item = 0; | 184 | qDebug( "refreshMailView not reached" ); |
182 | mailView->clear(); | ||
183 | for (unsigned int i = 0; i < list->count();++i) { | ||
184 | item = new MailListViewItem(mailView,item); | ||
185 | item->storeData(*(list->at(i))); | ||
186 | item->showEntry(); | ||
187 | } | ||
188 | } | 185 | } |
189 | void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | 186 | |
187 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) | ||
190 | { | 188 | { |
191 | /* just LEFT button - or tap with stylus on pda */ | 189 | qDebug( "mailLeftClicked not reached" ); |
192 | if (button!=1) return; | ||
193 | if (!item) return; | ||
194 | displayMail(); | ||
195 | } | 190 | } |
@@ -198,17 +193,3 @@ void MainWindow::displayMail() | |||
198 | { | 193 | { |
199 | QListViewItem*item = mailView->currentItem(); | 194 | qDebug("displayMail not reached"); |
200 | if (!item) return; | ||
201 | RecMail mail = ((MailListViewItem*)item)->data(); | ||
202 | RecBody body = folderView->fetchBody(mail); | ||
203 | ViewMail readMail( this ); | ||
204 | readMail.setBody( body ); | ||
205 | readMail.setMail( mail ); | ||
206 | readMail.showMaximized(); | ||
207 | readMail.exec(); | ||
208 | |||
209 | if ( readMail.deleted ) { | ||
210 | folderView->refreshCurrent(); | ||
211 | } else { | ||
212 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); | ||
213 | } | ||
214 | } | 195 | } |
@@ -217,88 +198,8 @@ void MainWindow::slotDeleteMail() | |||
217 | { | 198 | { |
218 | if (!mailView->currentItem()) return; | 199 | qDebug("deleteMail not reached"); |
219 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | ||
220 | 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 ) { | ||
221 | mail.Wrapper()->deleteMail( mail ); | ||
222 | folderView->refreshCurrent(); | ||
223 | } | ||
224 | } | ||
225 | |||
226 | void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int ) | ||
227 | { | ||
228 | /* just the RIGHT button - or hold on pda */ | ||
229 | if (button!=2) {return;} | ||
230 | qDebug("Event right/hold"); | ||
231 | if (!item) return; | ||
232 | QPopupMenu *m = new QPopupMenu(0); | ||
233 | if (m) { | ||
234 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | ||
235 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | ||
236 | m->setFocus(); | ||
237 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | ||
238 | delete m; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | ||
243 | :QListViewItem(parent,item),mail_data() | ||
244 | { | ||
245 | } | ||
246 | |||
247 | void MailListViewItem::showEntry() | ||
248 | { | ||
249 | if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { | ||
250 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); | ||
251 | } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { | ||
252 | /* I think it looks nicer if there are not such a log of icons but only on mails | ||
253 | replied or new - Alwin*/ | ||
254 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); | ||
255 | } else { | ||
256 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); | ||
257 | } | ||
258 | double s = mail_data.Msgsize(); | ||
259 | int w; | ||
260 | w=0; | ||
261 | |||
262 | while (s>1024) { | ||
263 | s/=1024; | ||
264 | ++w; | ||
265 | if (w>=2) break; | ||
266 | } | ||
267 | |||
268 | QString q=""; | ||
269 | QString fsize=""; | ||
270 | switch(w) { | ||
271 | case 1: | ||
272 | q="k"; | ||
273 | break; | ||
274 | case 2: | ||
275 | q="M"; | ||
276 | break; | ||
277 | default: | ||
278 | break; | ||
279 | } | ||
280 | |||
281 | { | ||
282 | QTextOStream o(&fsize); | ||
283 | if (w>0) o.precision(2); else o.precision(0); | ||
284 | o.setf(QTextStream::fixed); | ||
285 | o << s << " " << q << "Byte"; | ||
286 | } | ||
287 | |||
288 | setText(1,mail_data.getSubject()); | ||
289 | setText(2,mail_data.getFrom()); | ||
290 | setText(3,fsize); | ||
291 | setText(4,mail_data.getDate()); | ||
292 | } | 200 | } |
293 | 201 | ||
294 | void MailListViewItem::storeData(const RecMail&data) | 202 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
295 | { | 203 | { |
296 | mail_data = data; | 204 | qDebug("mailHold not reached"); |
297 | } | 205 | } |
298 | |||
299 | const RecMail& MailListViewItem::data()const | ||
300 | { | ||
301 | return mail_data; | ||
302 | } | ||
303 | |||
304 | |||
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 15d216a..20614cc 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h | |||
@@ -25,2 +25,3 @@ public slots: | |||
25 | virtual void slotAdjustColumns(); | 25 | virtual void slotAdjustColumns(); |
26 | virtual void appMessage(const QCString &msg, const QByteArray &data); | ||
26 | 27 | ||
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index c888708..dee3f70 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -7,4 +7,9 @@ | |||
7 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
8 | #include <qpe/resource.h> | ||
8 | #include <qaction.h> | 9 | #include <qaction.h> |
9 | #include <qapplication.h> | 10 | #include <qapplication.h> |
11 | #include <libmailwrapper/mailtypes.h> | ||
12 | #include "mailistviewitem.h" | ||
13 | #include "viewmail.h" | ||
14 | #include "selectstore.h" | ||
10 | 15 | ||
@@ -16,16 +21,2 @@ OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | |||
16 | folderView->populate( settings->getAccounts() ); | 21 | folderView->populate( settings->getAccounts() ); |
17 | |||
18 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | ||
19 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | ||
20 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | ||
21 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | ||
22 | // Added by Stefan Eilers to allow starting by addressbook.. | ||
23 | // copied from old mail2 | ||
24 | #if !defined(QT_NO_COP) | ||
25 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), | ||
26 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | ||
27 | #endif | ||
28 | |||
29 | |||
30 | |||
31 | } | 22 | } |
@@ -120 +111,101 @@ void OpieMail::slotEditAccounts() | |||
120 | 111 | ||
112 | void OpieMail::displayMail() | ||
113 | { | ||
114 | QListViewItem*item = mailView->currentItem(); | ||
115 | if (!item) return; | ||
116 | RecMail mail = ((MailListViewItem*)item)->data(); | ||
117 | RecBody body = folderView->fetchBody(mail); | ||
118 | ViewMail readMail( this ); | ||
119 | readMail.setBody( body ); | ||
120 | readMail.setMail( mail ); | ||
121 | readMail.showMaximized(); | ||
122 | readMail.exec(); | ||
123 | |||
124 | if ( readMail.deleted ) { | ||
125 | folderView->refreshCurrent(); | ||
126 | } else { | ||
127 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | void OpieMail::slotDeleteMail() | ||
132 | { | ||
133 | if (!mailView->currentItem()) return; | ||
134 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | ||
135 | 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 ) { | ||
136 | mail.Wrapper()->deleteMail( mail ); | ||
137 | folderView->refreshCurrent(); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | ||
142 | { | ||
143 | /* just the RIGHT button - or hold on pda */ | ||
144 | if (button!=2) {return;} | ||
145 | qDebug("Event right/hold"); | ||
146 | if (!item) return; | ||
147 | QPopupMenu *m = new QPopupMenu(0); | ||
148 | if (m) { | ||
149 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | ||
150 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | ||
151 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | ||
152 | m->setFocus(); | ||
153 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | ||
154 | delete m; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | void OpieMail::slotShowFolders( bool show ) | ||
159 | { | ||
160 | qDebug( "Show Folders" ); | ||
161 | if ( show && folderView->isHidden() ) { | ||
162 | qDebug( "-> showing" ); | ||
163 | folderView->show(); | ||
164 | } else if ( !show && !folderView->isHidden() ) { | ||
165 | qDebug( "-> hiding" ); | ||
166 | folderView->hide(); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | void OpieMail::refreshMailView(QList<RecMail>*list) | ||
171 | { | ||
172 | MailListViewItem*item = 0; | ||
173 | mailView->clear(); | ||
174 | for (unsigned int i = 0; i < list->count();++i) { | ||
175 | item = new MailListViewItem(mailView,item); | ||
176 | item->storeData(*(list->at(i))); | ||
177 | item->showEntry(); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | ||
182 | { | ||
183 | /* just LEFT button - or tap with stylus on pda */ | ||
184 | if (button!=1) return; | ||
185 | if (!item) return; | ||
186 | displayMail(); | ||
187 | } | ||
188 | |||
189 | void OpieMail::slotMoveCopyMail() | ||
190 | { | ||
191 | if (!mailView->currentItem()) return; | ||
192 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | ||
193 | AbstractMail*targetMail = 0; | ||
194 | QString targetFolder = ""; | ||
195 | Selectstore sels; | ||
196 | folderView->setupFolderselect(&sels); | ||
197 | if (!sels.exec()) return; | ||
198 | targetMail = sels.currentMail(); | ||
199 | targetFolder = sels.currentFolder(); | ||
200 | if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || | ||
201 | targetFolder.isEmpty()) { | ||
202 | return; | ||
203 | } | ||
204 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { | ||
205 | QMessageBox::critical(0,tr("Error creating new Folder"), | ||
206 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | ||
207 | return; | ||
208 | } | ||
209 | mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | ||
210 | folderView->refreshCurrent(); | ||
211 | } | ||
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h index 69b8d43..5821856 100644 --- a/noncore/net/mail/opiemail.h +++ b/noncore/net/mail/opiemail.h | |||
@@ -25,2 +25,10 @@ protected slots: | |||
25 | virtual void slotEditAccounts(); | 25 | virtual void slotEditAccounts(); |
26 | virtual void displayMail(); | ||
27 | virtual void slotDeleteMail(); | ||
28 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | ||
29 | virtual void slotShowFolders( bool show ); | ||
30 | virtual void refreshMailView(QList<RecMail>*); | ||
31 | virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); | ||
32 | virtual void slotMoveCopyMail(); | ||
33 | |||
26 | private: | 34 | private: |