Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mailitwindow.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2001 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qt Palmtop Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #include <qwhatsthis.h>
00021 #include <qmessagebox.h>
00022 #include "mailitwindow.h"
00023 
00024 MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags /*fl*/)
00025   : QMainWindow(parent, name, WStyle_ContextHelp)
00026 {
00027   currentCaption = tr("Mailit");
00028   setCaption(tr(currentCaption));
00029   views = new QWidgetStack(this);
00030   setCentralWidget(views);
00031   QWhatsThis::add(views,tr("Central view area"));
00032   emailClient = new EmailClient(views, "client");
00033   writeMail = new WriteMail(views, "writing");
00034   readMail = new ReadMail(views, "reading");
00035 
00036   views->raiseWidget(emailClient);
00037                         
00038   connect(emailClient, SIGNAL(composeRequested()),
00039     this, SLOT(compose()) );
00040   connect(emailClient, SIGNAL(viewEmail(QListView*,Email*)), this,
00041       SLOT(viewMail(QListView*,Email*)) );
00042   connect(emailClient, SIGNAL(mailUpdated(Email*)), this,
00043       SLOT(updateMailView(Email*)) );
00044 
00045   connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
00046   connect(writeMail, SIGNAL(sendMailRequested(const Email&)), this,
00047       SLOT(showEmailClient()) );
00048   connect(writeMail, SIGNAL(sendMailRequested(const Email&)), emailClient,
00049       SLOT(enqueMail(const Email&)) );
00050   
00051   connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
00052   connect(readMail, SIGNAL(replyRequested(Email&,bool&)), this,
00053     SLOT(composeReply(Email&,bool&)) );
00054   connect(readMail, SIGNAL(forwardRequested(Email&)), this,
00055     SLOT(composeForward(Email&)) );
00056 
00057   connect(readMail, SIGNAL(removeItem(EmailListItem*,bool&)), emailClient,
00058     SLOT(deleteMail(EmailListItem*,bool&)) );
00059   connect(readMail, SIGNAL(viewingMail(Email*)), emailClient,
00060     SLOT(moveMailFront(Email*)) );
00061   
00062   connect(emailClient, SIGNAL(newCaption(const QString&)),
00063     this, SLOT(updateCaption(const QString&)) );
00064     
00065   connect(readMail, SIGNAL(download(Email*)), emailClient, SLOT(download(Email*)) );
00066   
00067   viewingMail = FALSE;  
00068 }
00069 
00070 MailItWindow::~MailItWindow()
00071 {
00072 }
00073 
00074 void MailItWindow::closeEvent(QCloseEvent *e)
00075 {
00076   if (views->visibleWidget() == emailClient) {
00077     e->accept();
00078   } else {
00079     showEmailClient();
00080   }
00081 }
00082 
00083 void MailItWindow::compose()
00084 {
00085   viewingMail = FALSE;
00086   emailClient->hide();
00087   readMail->hide();
00088   views->raiseWidget(writeMail);
00089   writeMail->setAddressList(emailClient->getAdrListRef());
00090   writeMail->newMail();  
00091   setCaption( tr( "Write mail"  ) );
00092 }
00093 
00094 void MailItWindow::composeReply(Email &mail, bool& replyAll)
00095 {
00096   compose();
00097   writeMail->reply(mail,replyAll) ;
00098 }
00099 
00100 void MailItWindow::composeForward(Email &mail)
00101 {
00102   compose();
00103   writeMail->forward(mail) ;
00104 }
00105 
00106 
00107 void MailItWindow::showEmailClient()
00108 {
00109   viewingMail = FALSE;
00110   writeMail->hide();
00111   readMail->hide();
00112   views->raiseWidget(emailClient);
00113   setCaption( tr(currentCaption) );
00114 }
00115 
00116 void MailItWindow::viewMail(QListView *view, Email *mail)
00117 {
00118   viewingMail = TRUE;
00119   emailClient->hide();
00120   
00121   int result=0;
00122   
00123   if ((mail->received)&&(!mail->downloaded))
00124   {   
00125     QMessageBox mb( tr("Mail not downloaded"),
00126                     tr("The mail you have clicked \n"
00127         "has not been downloaded yet.\n "
00128         "Would you like to do it now ?"),
00129                     QMessageBox::Information,
00130                     QMessageBox::Yes | QMessageBox::Default,
00131                     QMessageBox::No | QMessageBox::Escape,0 );
00132      
00133   result=mb.exec();
00134   
00135   if (result==QMessageBox::Yes)
00136   {
00137     emailClient->download(mail);
00138   }
00139   }
00140   
00141   readMail->update(view, mail);
00142   views->raiseWidget(readMail);
00143   setCaption( tr( "Read Mail"  ) );
00144 }
00145 
00146 void MailItWindow::updateMailView(Email *mail)
00147 {
00148   if (viewingMail) {
00149     readMail->mailUpdated(mail);
00150   }
00151 }
00152 
00153 void MailItWindow::updateCaption(const QString &newCaption)
00154 {
00155   currentCaption = newCaption;
00156   setCaption(tr(currentCaption));
00157 }
00158 
00159 void MailItWindow::setDocument(const QString &_address)
00160 {
00161     // strip leading 'mailto:'
00162     QString address = _address;
00163     if (address.startsWith("mailto:"))
00164         address = address.mid(6);
00165  
00166     compose();
00167     writeMail->setRecipient(address);
00168 }

Generated on Sat Nov 5 16:18:09 2005 for OPIE by  doxygen 1.4.2