summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index d522ad0..3fbdcec 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,48 +1,49 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
2 3
3#include "settingsdialog.h" 4#include "settingsdialog.h"
4#include "opiemail.h" 5#include "opiemail.h"
5#include "editaccounts.h" 6#include "editaccounts.h"
6#include "composemail.h" 7#include "composemail.h"
7#include "mailistviewitem.h" 8#include "mailistviewitem.h"
8#include "viewmail.h" 9#include "viewmail.h"
9#include "selectstore.h" 10#include "selectstore.h"
10#include "selectsmtp.h" 11#include "selectsmtp.h"
11 12
12#include <qmessagebox.h> 13#include <qmessagebox.h>
13 14
14#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
15#include <libmailwrapper/smtpwrapper.h> 16#include <libmailwrapper/smtpwrapper.h>
16#include <libmailwrapper/mailtypes.h> 17#include <libmailwrapper/mailtypes.h>
17#include <libmailwrapper/abstractmail.h> 18#include <libmailwrapper/abstractmail.h>
18/* OPIE */ 19/* OPIE */
19//#include <qpe/resource.h> 20//#include <qpe/resource.h>
20#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
21 22
22/* QT */ 23/* QT */
23 24
24using namespace Opie::Core; 25using namespace Opie::Core;
25 26
26OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
27 : MainWindow( parent, name) //, WStyle_ContextHelp ) 28 : MainWindow( parent, name) //, WStyle_ContextHelp )
28{ 29{
29 settings = new Settings(); 30 settings = new Settings();
30 31
31 folderView->populate( settings->getAccounts() ); 32 folderView->populate( settings->getAccounts() );
32 33
33} 34}
34 35
35OpieMail::~OpieMail() 36OpieMail::~OpieMail()
36{ 37{
37 if (settings) delete settings; 38 if (settings) delete settings;
38} 39}
39 40
40void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 41void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
41{ 42{
42 43
43} 44}
44#include <stdlib.h> 45#include <stdlib.h>
45void OpieMail::message(const QCString &msg, const QByteArray &data) 46void OpieMail::message(const QCString &msg, const QByteArray &data)
46{ 47{
47 // copied from old mail2 48 // copied from old mail2
48 static int ii = 0; 49 static int ii = 0;
@@ -233,132 +234,175 @@ void OpieMail::slotDeleteMail()
233 mail->Wrapper()->deleteMail( mail ); 234 mail->Wrapper()->deleteMail( mail );
234 folderView->refreshCurrent(); 235 folderView->refreshCurrent();
235 } 236 }
236} 237}
237void OpieMail::slotDeleteAllMail() 238void OpieMail::slotDeleteAllMail()
238{ 239{
239 if (!mailView->currentItem()) return; 240 if (!mailView->currentItem()) return;
240 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 241 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
241 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 242 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
242 { 243 {
243 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 244 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
244 while ( item ) { 245 while ( item ) {
245 if ( item->isSelected() ) { 246 if ( item->isSelected() ) {
246 RecMailP mail = item->data(); 247 RecMailP mail = item->data();
247 mail->Wrapper()->deleteMail( mail ); 248 mail->Wrapper()->deleteMail( mail );
248 } 249 }
249 item = (MailListViewItem*)item->nextSibling(); 250 item = (MailListViewItem*)item->nextSibling();
250 } 251 }
251 folderView->refreshCurrent(); 252 folderView->refreshCurrent();
252 } 253 }
253} 254}
254void OpieMail::clearSelection() 255void OpieMail::clearSelection()
255{ 256{
256 mailView->clearSelection(); 257 mailView->clearSelection();
257 258
258} 259}
259 260
260void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 261void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
261{ 262{
262 if (!mailView->currentItem()) return; 263 if (!mailView->currentItem()) return;
263 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 264 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
264 /* just the RIGHT button - or hold on pda */ 265 /* just the RIGHT button - or hold on pda */
265 if (button!=2) {return;} 266 if (button!=2) {return;}
266 if (!item) return; 267 if (!item) return;
267 QPopupMenu *m = new QPopupMenu(0); 268 QPopupMenu *m = new QPopupMenu(0);
268 if (m) 269 if (m)
269 { 270 {
270 if (mailtype==MAILLIB::A_NNTP) { 271 if (mailtype==MAILLIB::A_NNTP) {
271 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 272 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
272// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 273// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
273 } else { 274 } else {
274 if (folderView->currentisDraft()) { 275 if (folderView->currentisDraft()) {
275 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 276 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
276 } 277 }
277 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 278 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
278 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 279 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
279 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 280 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
280 m->insertSeparator(); 281 m->insertSeparator();
282 m->insertItem(tr("Copy/Move all selected mail"),this,SLOT(slotMoveCopyAllMail()));
281 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 283 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
282 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); 284 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
283 } 285 }
284 m->setFocus(); 286 m->setFocus();
285 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 287 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
286 delete m; 288 delete m;
287 } 289 }
288} 290}
289 291
290void OpieMail::slotShowFolders( bool show ) 292void OpieMail::slotShowFolders( bool show )
291{ 293{
292 if ( show && folderView->isHidden() ) 294 if ( show && folderView->isHidden() )
293 { 295 {
294 folderView->show(); 296 folderView->show();
295 } 297 }
296 else if ( !show && !folderView->isHidden() ) 298 else if ( !show && !folderView->isHidden() )
297 { 299 {
298 folderView->hide(); 300 folderView->hide();
299 } 301 }
300} 302}
301 303
302void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 304void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
303{ 305{
304 MailListViewItem*item = 0; 306 MailListViewItem*item = 0;
305 mailView->clear(); 307 mailView->clear();
306 308
307 QValueList<RecMailP>::ConstIterator it; 309 QValueList<RecMailP>::ConstIterator it;
308 for (it = list.begin(); it != list.end();++it) 310 for (it = list.begin(); it != list.end();++it)
309 { 311 {
310 item = new MailListViewItem(mailView,item); 312 item = new MailListViewItem(mailView,item);
311 item->storeData((*it)); 313 item->storeData((*it));
312 item->showEntry(); 314 item->showEntry();
313 } 315 }
314} 316}
315 317
316void OpieMail::mailLeftClicked( QListViewItem *item ) 318void OpieMail::mailLeftClicked( QListViewItem *item )
317{ 319{
318 mailView->clearSelection(); 320 mailView->clearSelection();
319 /* just LEFT button - or tap with stylus on pda */ 321 /* just LEFT button - or tap with stylus on pda */
320 //if (button!=1) return; 322 //if (button!=1) return;
321 if (!item) return; 323 if (!item) return;
322 if (folderView->currentisDraft()) { 324 if (folderView->currentisDraft()) {
323 reEditMail(); 325 reEditMail();
324 } else { 326 } else {
325 displayMail(); 327 displayMail();
326 } 328 }
327} 329}
328 330
329void OpieMail::slotMoveCopyMail() 331void OpieMail::slotMoveCopyMail()
330{ 332{
331 if (!mailView->currentItem()) return; 333 if (!mailView->currentItem()) return;
332 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 334 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
333 AbstractMail*targetMail = 0; 335 AbstractMail*targetMail = 0;
334 QString targetFolder = ""; 336 QString targetFolder = "";
335 Selectstore sels; 337 Selectstore sels;
336 folderView->setupFolderselect(&sels); 338 folderView->setupFolderselect(&sels);
337 if (!sels.exec()) return; 339 if (!sels.exec()) return;
338 targetMail = sels.currentMail(); 340 targetMail = sels.currentMail();
339 targetFolder = sels.currentFolder(); 341 targetFolder = sels.currentFolder();
340 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 342 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
341 targetFolder.isEmpty()) 343 targetFolder.isEmpty())
342 { 344 {
343 return; 345 return;
344 } 346 }
345 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 347 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
346 { 348 {
347 QMessageBox::critical(0,tr("Error creating new Folder"), 349 QMessageBox::critical(0,tr("Error creating new Folder"),
348 tr("<center>Error while creating<br>new folder - breaking.</center>")); 350 tr("<center>Error while creating<br>new folder - breaking.</center>"));
349 return; 351 return;
350 } 352 }
351 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 353 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
352 folderView->refreshCurrent(); 354 folderView->refreshCurrent();
353} 355}
354 356
357void OpieMail::slotMoveCopyAllMail()
358{
359
360 if (!mailView->currentItem()) return;
361 QValueList<RecMailP> t;
362 if ( QMessageBox::warning(this, tr("Copy/Move all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
363 {
364 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
365 while ( item ) {
366 if ( item->isSelected() ) {
367 t.append( item->data() );
368 }
369 item = (MailListViewItem*)item->nextSibling();
370 }
371 }
372 else
373 return;
374 if ( t.count() == 0 )
375 return;
376 RecMailP mail = t.first();
377 AbstractMail*targetMail = 0;
378 QString targetFolder = "";
379 Selectstore sels;
380 folderView->setupFolderselect(&sels);
381 if (!sels.exec()) return;
382 targetMail = sels.currentMail();
383 targetFolder = sels.currentFolder();
384 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
385 targetFolder.isEmpty())
386 {
387 return;
388 }
389 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
390 {
391 QMessageBox::critical(0,tr("Error creating new Folder"),
392 tr("<center>Error while creating<br>new folder - breaking.</center>"));
393 return;
394 }
395 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
396 folderView->refreshCurrent();
397}
398
355void OpieMail::reEditMail() 399void OpieMail::reEditMail()
356{ 400{
357 if (!mailView->currentItem()) return; 401 if (!mailView->currentItem()) return;
358 402
359 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 403 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
360 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 404 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
361 compose.slotAdjustColumns(); 405 compose.slotAdjustColumns();
362 compose.showMaximized(); 406 compose.showMaximized();
363 compose.exec(); 407 compose.exec();
364} 408}