Diffstat (limited to 'noncore/net/mail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/composemail.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index 88dd780..96787e4 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -1,64 +1,65 @@ | |||
1 | #include <qt.h> | 1 | #include <qt.h> |
2 | 2 | ||
3 | #include <opie/ofiledialog.h> | 3 | #include <opie/ofiledialog.h> |
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | 5 | ||
6 | #include "composemail.h" | 6 | #include "composemail.h" |
7 | 7 | ||
8 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 8 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
9 | : ComposeMailUI( parent, name, modal, flags ) | 9 | : ComposeMailUI( parent, name, modal, flags ) |
10 | { | 10 | { |
11 | settings = s; | 11 | settings = s; |
12 | 12 | ||
13 | attList->addColumn( tr( "Name" ) ); | 13 | attList->addColumn( tr( "Name" ) ); |
14 | attList->addColumn( tr( "Size" ) ); | 14 | attList->addColumn( tr( "Size" ) ); |
15 | 15 | ||
16 | QList<Account> accounts = settings->getAccounts(); | 16 | QList<Account> accounts = settings->getAccounts(); |
17 | Account *it; | 17 | Account *it; |
18 | for ( it = accounts.first(); it; it = accounts.next() ) { | 18 | for ( it = accounts.first(); it; it = accounts.next() ) { |
19 | if ( it->getType().compare( "SMTP" ) == 0 ) { | 19 | if ( it->getType().compare( "SMTP" ) == 0 ) { |
20 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 20 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
21 | fromBox->insertItem( smtp->getMail() ); | 21 | fromBox->insertItem( smtp->getMail() ); |
22 | smtpAccounts.append( smtp ); | 22 | smtpAccounts.append( smtp ); |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | if ( smtpAccounts.count() > 0 ) { | 26 | if ( smtpAccounts.count() > 0 ) { |
27 | fillValues( fromBox->currentItem() ); | 27 | fillValues( fromBox->currentItem() ); |
28 | } else { | 28 | } else { |
29 | QMessageBox::information( this, tr( "Problem" ), | 29 | QMessageBox::information( this, tr( "Problem" ), |
30 | tr( "<p>Please create an SMTP account first.</p>" ), | 30 | tr( "<p>Please create an SMTP account first.</p>" ), |
31 | tr( "Ok" ) ); | 31 | tr( "Ok" ) ); |
32 | } | 32 | } |
33 | 33 | ||
34 | connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); | 34 | connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); |
35 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 35 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
36 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 36 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
37 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 37 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
38 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 38 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
39 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 39 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
40 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 40 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
41 | } | 41 | } |
42 | 42 | ||
43 | void ComposeMail::pickAddress( QLineEdit *line ) | 43 | void ComposeMail::pickAddress( QLineEdit *line ) |
44 | { | 44 | { |
45 | QString names = AddressPicker::getNames(); | 45 | QString names = AddressPicker::getNames(); |
46 | if ( line->text().isEmpty() ) { | 46 | if ( line->text().isEmpty() ) { |
47 | line->setText( names ); | 47 | line->setText( names ); |
48 | } else if ( !names.isEmpty() ) { | 48 | } else if ( !names.isEmpty() ) { |
49 | line->setText( line->text() + ", " + names ); | 49 | line->setText( line->text() + ", " + names ); |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | |||
53 | void ComposeMail::pickAddressTo() | 54 | void ComposeMail::pickAddressTo() |
54 | { | 55 | { |
55 | pickAddress( toLine ); | 56 | pickAddress( toLine ); |
56 | } | 57 | } |
57 | 58 | ||
58 | void ComposeMail::pickAddressCC() | 59 | void ComposeMail::pickAddressCC() |
59 | { | 60 | { |
60 | pickAddress( ccLine ); | 61 | pickAddress( ccLine ); |
61 | } | 62 | } |
62 | 63 | ||
63 | void ComposeMail::pickAddressBCC() | 64 | void ComposeMail::pickAddressBCC() |
64 | { | 65 | { |
@@ -84,55 +85,55 @@ void ComposeMail::fillValues( int current ) | |||
84 | } | 85 | } |
85 | replyLine->clear(); | 86 | replyLine->clear(); |
86 | if ( smtp->getUseReply() ) { | 87 | if ( smtp->getUseReply() ) { |
87 | replyLine->setText( smtp->getReply() ); | 88 | replyLine->setText( smtp->getReply() ); |
88 | } | 89 | } |
89 | 90 | ||
90 | sigMultiLine->setText( smtp->getSignature() ); | 91 | sigMultiLine->setText( smtp->getSignature() ); |
91 | } | 92 | } |
92 | 93 | ||
93 | void ComposeMail::slotAdjustColumns() | 94 | void ComposeMail::slotAdjustColumns() |
94 | { | 95 | { |
95 | int currPage = tabWidget->currentPageIndex(); | 96 | int currPage = tabWidget->currentPageIndex(); |
96 | 97 | ||
97 | tabWidget->showPage( attachTab ); | 98 | tabWidget->showPage( attachTab ); |
98 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 99 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
99 | attList->setColumnWidth( 1, 80 ); | 100 | attList->setColumnWidth( 1, 80 ); |
100 | 101 | ||
101 | tabWidget->setCurrentPage( currPage ); | 102 | tabWidget->setCurrentPage( currPage ); |
102 | } | 103 | } |
103 | 104 | ||
104 | void ComposeMail::addAttachment() | 105 | void ComposeMail::addAttachment() |
105 | { | 106 | { |
106 | DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); | 107 | DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); |
107 | if ( !lnk.name().isEmpty() ) { | 108 | if ( !lnk.name().isEmpty() ) { |
108 | Attachment *att = new Attachment( lnk ); | 109 | Attachment *att = new Attachment( lnk ); |
109 | (void) new AttachViewItem( attList, att ); | 110 | (void) new AttachViewItem( attList, att ); |
110 | } | 111 | } |
111 | } | 112 | } |
112 | 113 | ||
113 | void ComposeMail::removeAttachment() | 114 | void ComposeMail::removeAttachment() |
114 | { | 115 | { |
115 | if ( !attList->currentItem() ) { | 116 | if ( !attList->currentItem() ) { |
116 | QMessageBox::information( this, tr( "Error" ), | 117 | QMessageBox::information( this, tr( "Error" ), |
117 | tr( "<p>Please select a File.</p>" ), | 118 | tr( "<p>Please select a File.</p>" ), |
118 | tr( "Ok" ) ); | 119 | tr( "Ok" ) ); |
119 | } else { | 120 | } else { |
120 | attList->takeItem( attList->currentItem() ); | 121 | attList->takeItem( attList->currentItem() ); |
121 | } | 122 | } |
122 | } | 123 | } |
123 | 124 | ||
124 | void ComposeMail::accept() | 125 | void ComposeMail::accept() |
125 | { | 126 | { |
126 | qDebug( "Sending Mail with " + | 127 | qDebug( "Sending Mail with " + |
127 | smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); | 128 | smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); |
128 | Mail *mail = new Mail(); | 129 | Mail *mail = new Mail(); |
129 | SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); | 130 | SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); |
130 | mail->setMail( smtp->getMail() ); | 131 | mail->setMail( smtp->getMail() ); |
131 | mail->setName( smtp->getName() ); | 132 | mail->setName( smtp->getName() ); |
132 | 133 | ||
133 | if ( !toLine->text().isEmpty() ) { | 134 | if ( !toLine->text().isEmpty() ) { |
134 | mail->setTo( toLine->text() ); | 135 | mail->setTo( toLine->text() ); |
135 | } else { | 136 | } else { |
136 | qDebug( "No Reciever spezified -> returning" ); | 137 | qDebug( "No Reciever spezified -> returning" ); |
137 | return; | 138 | return; |
138 | } | 139 | } |
@@ -155,19 +156,19 @@ void ComposeMail::accept() | |||
155 | 156 | ||
156 | MailWrapper wrapper( settings ); | 157 | MailWrapper wrapper( settings ); |
157 | wrapper.sendMail( *mail ); | 158 | wrapper.sendMail( *mail ); |
158 | 159 | ||
159 | QDialog::accept(); | 160 | QDialog::accept(); |
160 | } | 161 | } |
161 | 162 | ||
162 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 163 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
163 | : QListViewItem( parent ) | 164 | : QListViewItem( parent ) |
164 | { | 165 | { |
165 | attachment = att; | 166 | attachment = att; |
166 | qDebug( att->getMimeType() ); | 167 | qDebug( att->getMimeType() ); |
167 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? | 168 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? |
168 | Resource::loadPixmap( "UnknownDocument-14" ) : | 169 | Resource::loadPixmap( "UnknownDocument-14" ) : |
169 | attachment->getDocLnk().pixmap() ); | 170 | attachment->getDocLnk().pixmap() ); |
170 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 171 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
171 | setText( 1, QString::number( att->getSize() ) ); | 172 | setText( 1, QString::number( att->getSize() ) ); |
172 | } | 173 | } |
173 | 174 | ||