summaryrefslogtreecommitdiff
path: root/noncore/net/mailit/mailitwindow.cpp
Unidiff
Diffstat (limited to 'noncore/net/mailit/mailitwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/mailitwindow.cpp168
1 files changed, 0 insertions, 168 deletions
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp
deleted file mode 100644
index 6e298c7..0000000
--- a/noncore/net/mailit/mailitwindow.cpp
+++ b/dev/null
@@ -1,168 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qwhatsthis.h>
21#include <qmessagebox.h>
22#include "mailitwindow.h"
23
24MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags /*fl*/)
25 : QMainWindow(parent, name, WStyle_ContextHelp)
26{
27 currentCaption = tr("Mailit");
28 setCaption(tr(currentCaption));
29 views = new QWidgetStack(this);
30 setCentralWidget(views);
31 QWhatsThis::add(views,tr("Central view area"));
32 emailClient = new EmailClient(views, "client");
33 writeMail = new WriteMail(views, "writing");
34 readMail = new ReadMail(views, "reading");
35
36 views->raiseWidget(emailClient);
37
38 connect(emailClient, SIGNAL(composeRequested()),
39 this, SLOT(compose()) );
40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this,
41 SLOT(viewMail(QListView *, Email *)) );
42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this,
43 SLOT(updateMailView(Email *)) );
44
45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
47 SLOT(showEmailClient()) );
48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient,
49 SLOT(enqueMail(const Email &)) );
50
51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
52 connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this,
53 SLOT(composeReply(Email &, bool&)) );
54 connect(readMail, SIGNAL(forwardRequested(Email &)), this,
55 SLOT(composeForward(Email &)) );
56
57 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient,
58 SLOT(deleteMail(EmailListItem *, bool &)) );
59 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient,
60 SLOT(moveMailFront(Email *)) );
61
62 connect(emailClient, SIGNAL(newCaption(const QString &)),
63 this, SLOT(updateCaption(const QString &)) );
64
65 connect(readMail, SIGNAL(download(Email *)), emailClient, SLOT(download(Email*)) );
66
67 viewingMail = FALSE;
68}
69
70MailItWindow::~MailItWindow()
71{
72}
73
74void MailItWindow::closeEvent(QCloseEvent *e)
75{
76 if (views->visibleWidget() == emailClient) {
77 e->accept();
78 } else {
79 showEmailClient();
80 }
81}
82
83void MailItWindow::compose()
84{
85 viewingMail = FALSE;
86 emailClient->hide();
87 readMail->hide();
88 views->raiseWidget(writeMail);
89 writeMail->setAddressList(emailClient->getAdrListRef());
90 writeMail->newMail();
91 setCaption( tr( "Write mail" ) );
92}
93
94void MailItWindow::composeReply(Email &mail, bool& replyAll)
95{
96 compose();
97 writeMail->reply(mail,replyAll) ;
98}
99
100void MailItWindow::composeForward(Email &mail)
101{
102 compose();
103 writeMail->forward(mail) ;
104}
105
106
107void MailItWindow::showEmailClient()
108{
109 viewingMail = FALSE;
110 writeMail->hide();
111 readMail->hide();
112 views->raiseWidget(emailClient);
113 setCaption( tr(currentCaption) );
114}
115
116void MailItWindow::viewMail(QListView *view, Email *mail)
117{
118 viewingMail = TRUE;
119 emailClient->hide();
120
121 int result=0;
122
123 if ((mail->received)&&(!mail->downloaded))
124 {
125 QMessageBox mb( tr("Mail not downloaded"),
126 tr("The mail you have clicked \n"
127 "has not been downloaded yet.\n "
128 "Would you like to do it now ?"),
129 QMessageBox::Information,
130 QMessageBox::Yes | QMessageBox::Default,
131 QMessageBox::No | QMessageBox::Escape,0 );
132
133 result=mb.exec();
134
135 if (result==QMessageBox::Yes)
136 {
137 emailClient->download(mail);
138 }
139 }
140
141 readMail->update(view, mail);
142 views->raiseWidget(readMail);
143 setCaption( tr( "Read Mail" ) );
144}
145
146void MailItWindow::updateMailView(Email *mail)
147{
148 if (viewingMail) {
149 readMail->mailUpdated(mail);
150 }
151}
152
153void MailItWindow::updateCaption(const QString &newCaption)
154{
155 currentCaption = newCaption;
156 setCaption(tr(currentCaption));
157}
158
159void MailItWindow::setDocument(const QString &_address)
160{
161 // strip leading 'mailto:'
162 QString address = _address;
163 if (address.startsWith("mailto:"))
164 address = address.mid(6);
165
166 compose();
167 writeMail->setRecipient(address);
168}