From 70b1ff1a3f134d75d1539f269d52b34e6762684d Mon Sep 17 00:00:00 2001 From: llornkcor Date: Sun, 06 Apr 2003 17:45:00 +0000 Subject: move malit to head again, since it is working --- (limited to 'noncore/unsupported/mailit/mailitwindow.cpp') diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp new file mode 100644 index 0000000..f9b6de2 --- a/dev/null +++ b/noncore/unsupported/mailit/mailitwindow.cpp @@ -0,0 +1,132 @@ +/********************************************************************** +** Copyright (C) 2001 Trolltech AS. All rights reserved. +** +** This file is part of Qt Palmtop Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#include "mailitwindow.h" + +MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) + : QMainWindow(parent, name, fl) +{ + currentCaption = "Mailit"; + setCaption(tr(currentCaption)); + views = new QWidgetStack(this); + setCentralWidget(views); + + emailClient = new EmailClient(views, "client"); + writeMail = new WriteMail(views, "writing"); + readMail = new ReadMail(views, "reading"); + + views->raiseWidget(emailClient); + + connect(emailClient, SIGNAL(composeRequested()), + this, SLOT(compose()) ); + connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, + SLOT(viewMail(QListView *, Email *)) ); + connect(emailClient, SIGNAL(mailUpdated(Email *)), this, + SLOT(updateMailView(Email *)) ); + + connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); + connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, + SLOT(showEmailClient()) ); + connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, + SLOT(enqueMail(const Email &)) ); + + connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); + connect(readMail, SIGNAL(replyRequested(Email &)), this, + SLOT(composeReply(Email &)) ); + connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, + SLOT(deleteMail(EmailListItem *, bool &)) ); + connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, + SLOT(moveMailFront(Email *)) ); + + connect(emailClient, SIGNAL(newCaption(const QString &)), + this, SLOT(updateCaption(const QString &)) ); + viewingMail = FALSE; +} + +MailItWindow::~MailItWindow() +{ +} + +void MailItWindow::closeEvent(QCloseEvent *e) +{ + if (views->visibleWidget() == emailClient) { + e->accept(); + } else { + showEmailClient(); + } +} + +void MailItWindow::compose() +{ + viewingMail = FALSE; + emailClient->hide(); + readMail->hide(); + views->raiseWidget(writeMail); + writeMail->setAddressList(emailClient->getAdrListRef()); + setCaption( tr( "Write mail" ) ); +} + +void MailItWindow::composeReply(Email &mail) +{ + compose(); + writeMail->reply(mail); +} + +void MailItWindow::showEmailClient() +{ + viewingMail = FALSE; + writeMail->hide(); + readMail->hide(); + views->raiseWidget(emailClient); + setCaption( tr(currentCaption) ); +} + +void MailItWindow::viewMail(QListView *view, Email *mail) +{ + viewingMail = TRUE; + emailClient->hide(); + readMail->update(view, mail); + views->raiseWidget(readMail); + setCaption( tr( "Examine mail" ) ); +} + +void MailItWindow::updateMailView(Email *mail) +{ + if (viewingMail) { + readMail->mailUpdated(mail); + } +} + +void MailItWindow::updateCaption(const QString &newCaption) +{ + currentCaption = newCaption; + setCaption(tr(currentCaption)); +} + +void MailItWindow::setDocument(const QString &_address) +{ + // strip leading 'mailto:' + QString address = _address; + if (address.startsWith("mailto:")) + address = address.mid(6); + + compose(); + writeMail->setRecipient(address); +} + -- cgit v0.9.0.2