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