Diffstat (limited to 'noncore/net/mail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 119 |
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 | |||
@@ -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 | } | ||