Diffstat (limited to 'noncore/unsupported/mailit/mailitwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/mailitwindow.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
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 @@ | |||
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 "mailitwindow.h" | ||
21 | |||
22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) | ||
23 | : QMainWindow(parent, name, fl) | ||
24 | { | ||
25 | currentCaption = "Mailit"; | ||
26 | setCaption(tr(currentCaption)); | ||
27 | views = new QWidgetStack(this); | ||
28 | setCentralWidget(views); | ||
29 | |||
30 | emailClient = new EmailClient(views, "client"); | ||
31 | writeMail = new WriteMail(views, "writing"); | ||
32 | readMail = new ReadMail(views, "reading"); | ||
33 | |||
34 | views->raiseWidget(emailClient); | ||
35 | |||
36 | connect(emailClient, SIGNAL(composeRequested()), | ||
37 | this, SLOT(compose()) ); | ||
38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | ||
39 | SLOT(viewMail(QListView *, Email *)) ); | ||
40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | ||
41 | SLOT(updateMailView(Email *)) ); | ||
42 | |||
43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | ||
44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | ||
45 | SLOT(showEmailClient()) ); | ||
46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | ||
47 | SLOT(enqueMail(const Email &)) ); | ||
48 | |||
49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | ||
50 | connect(readMail, SIGNAL(replyRequested(Email &)), this, | ||
51 | SLOT(composeReply(Email &)) ); | ||
52 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | ||
53 | SLOT(deleteMail(EmailListItem *, bool &)) ); | ||
54 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | ||
55 | SLOT(moveMailFront(Email *)) ); | ||
56 | |||
57 | connect(emailClient, SIGNAL(newCaption(const QString &)), | ||
58 | this, SLOT(updateCaption(const QString &)) ); | ||
59 | viewingMail = FALSE; | ||
60 | } | ||
61 | |||
62 | MailItWindow::~MailItWindow() | ||
63 | { | ||
64 | } | ||
65 | |||
66 | void MailItWindow::closeEvent(QCloseEvent *e) | ||
67 | { | ||
68 | if (views->visibleWidget() == emailClient) { | ||
69 | e->accept(); | ||
70 | } else { | ||
71 | showEmailClient(); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | void MailItWindow::compose() | ||
76 | { | ||
77 | viewingMail = FALSE; | ||
78 | emailClient->hide(); | ||
79 | readMail->hide(); | ||
80 | views->raiseWidget(writeMail); | ||
81 | writeMail->setAddressList(emailClient->getAdrListRef()); | ||
82 | setCaption( tr( "Write mail" ) ); | ||
83 | } | ||
84 | |||
85 | void MailItWindow::composeReply(Email &mail) | ||
86 | { | ||
87 | compose(); | ||
88 | writeMail->reply(mail); | ||
89 | } | ||
90 | |||
91 | void MailItWindow::showEmailClient() | ||
92 | { | ||
93 | viewingMail = FALSE; | ||
94 | writeMail->hide(); | ||
95 | readMail->hide(); | ||
96 | views->raiseWidget(emailClient); | ||
97 | setCaption( tr(currentCaption) ); | ||
98 | } | ||
99 | |||
100 | void MailItWindow::viewMail(QListView *view, Email *mail) | ||
101 | { | ||
102 | viewingMail = TRUE; | ||
103 | emailClient->hide(); | ||
104 | readMail->update(view, mail); | ||
105 | views->raiseWidget(readMail); | ||
106 | setCaption( tr( "Examine mail" ) ); | ||
107 | } | ||
108 | |||
109 | void MailItWindow::updateMailView(Email *mail) | ||
110 | { | ||
111 | if (viewingMail) { | ||
112 | readMail->mailUpdated(mail); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | void MailItWindow::updateCaption(const QString &newCaption) | ||
117 | { | ||
118 | currentCaption = newCaption; | ||
119 | setCaption(tr(currentCaption)); | ||
120 | } | ||
121 | |||
122 | void MailItWindow::setDocument(const QString &_address) | ||
123 | { | ||
124 | // strip leading 'mailto:' | ||
125 | QString address = _address; | ||
126 | if (address.startsWith("mailto:")) | ||
127 | address = address.mid(6); | ||
128 | |||
129 | compose(); | ||
130 | writeMail->setRecipient(address); | ||
131 | } | ||
132 | |||