summaryrefslogtreecommitdiff
path: root/noncore/net/mail/opiemail.cpp
authoralwin <alwin>2004-01-08 14:04:54 (UTC)
committer alwin <alwin>2004-01-08 14:04:54 (UTC)
commitab6a32266c8fb625e782c601c9729af7f98904f6 (patch) (unidiff)
tree1457c421109359bdaa50082f2640d33ac4d74cc2 /noncore/net/mail/opiemail.cpp
parentb85bc4484bcc0a53557b4759c3e9e58dc9059138 (diff)
downloadopie-ab6a32266c8fb625e782c601c9729af7f98904f6.zip
opie-ab6a32266c8fb625e782c601c9729af7f98904f6.tar.gz
opie-ab6a32266c8fb625e782c601c9729af7f98904f6.tar.bz2
- store single message to another folder implemented
- cleaned code in mainwindow and opiemail.cpp
Diffstat (limited to 'noncore/net/mail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/opiemail.cpp119
1 files changed, 105 insertions, 14 deletions
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
@@ -2,35 +2,26 @@
2#include "settingsdialog.h" 2#include "settingsdialog.h"
3#include "opiemail.h" 3#include "opiemail.h"
4#include "editaccounts.h" 4#include "editaccounts.h"
5#include "composemail.h" 5#include "composemail.h"
6#include <libmailwrapper/smtpwrapper.h> 6#include <libmailwrapper/smtpwrapper.h>
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
11OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 16OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
12 : MainWindow( parent, name, flags ) 17 : MainWindow( parent, name, flags )
13{ 18{
14 settings = new Settings(); 19 settings = new Settings();
15 20
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}
32 23
33OpieMail::~OpieMail() 24OpieMail::~OpieMail()
34{ 25{
35 if (settings) delete settings; 26 if (settings) delete settings;
36} 27}
@@ -115,6 +106,106 @@ void OpieMail::slotEditAccounts()
115 if ( settings ) delete settings; 106 if ( settings ) delete settings;
116 settings = new Settings(); 107 settings = new Settings();
117 108
118 folderView->populate( settings->getAccounts() ); 109 folderView->populate( settings->getAccounts() );
119} 110}
120 111
112void 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
131void 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
141void 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
158void 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
170void 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
181void 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
189void 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}