summaryrefslogtreecommitdiffabout
path: root/kmicromail
Unidiff
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp1
-rw-r--r--kmicromail/mailistviewitem.cpp1
-rw-r--r--kmicromail/mailistviewitem.h1
-rw-r--r--kmicromail/main.cpp1
-rw-r--r--kmicromail/mainwindow.cpp2
-rw-r--r--kmicromail/mainwindow.h2
-rw-r--r--kmicromail/opiemail.cpp1
-rw-r--r--kmicromail/viewmail.cpp1
-rw-r--r--kmicromail/viewmailbase.cpp1
-rw-r--r--kmicromail/viewmailbase.h1
10 files changed, 12 insertions, 0 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 9060364..654cfc0 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -1,375 +1,376 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1 2
2#include "composemail.h" 3#include "composemail.h"
3 4
4#include <libmailwrapper/smtpwrapper.h> 5#include <libmailwrapper/smtpwrapper.h>
5#include <libmailwrapper/storemail.h> 6#include <libmailwrapper/storemail.h>
6#include <libmailwrapper/abstractmail.h> 7#include <libmailwrapper/abstractmail.h>
7#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
8 9
9/* OPIE */ 10/* OPIE */
10//#include <opie2/ofiledialog.h> 11//#include <opie2/ofiledialog.h>
11//#include <opie2/odebug.h> 12//#include <opie2/odebug.h>
12#include <kfiledialog.h> 13#include <kfiledialog.h>
13//#include <qpe/resource.h> 14//#include <qpe/resource.h>
14#include <qpe/config.h> 15#include <qpe/config.h>
15#include <qpe/global.h> 16#include <qpe/global.h>
16//#include <qpe/contact.h> 17//#include <qpe/contact.h>
17 18
18 19
19#include <qcombobox.h> 20#include <qcombobox.h>
20#include <qcheckbox.h> 21#include <qcheckbox.h>
21#include <qtimer.h> 22#include <qtimer.h>
22#include <qmessagebox.h> 23#include <qmessagebox.h>
23#include <qpushbutton.h> 24#include <qpushbutton.h>
24#include <qmultilineedit.h> 25#include <qmultilineedit.h>
25#include <qlabel.h> 26#include <qlabel.h>
26#include <qtabwidget.h> 27#include <qtabwidget.h>
27#include <qlistview.h> 28#include <qlistview.h>
28#include <kabc/addresseedialog.h> 29#include <kabc/addresseedialog.h>
29#include <kabc/stdaddressbook.h> 30#include <kabc/stdaddressbook.h>
30#include <kabc/addressee.h> 31#include <kabc/addressee.h>
31 32
32 33
33 34
34//using namespace Opie::Core; 35//using namespace Opie::Core;
35//using namespace Opie::Ui; 36//using namespace Opie::Ui;
36ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 37ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
37 : ComposeMailUI( parent, name, modal, flags ) 38 : ComposeMailUI( parent, name, modal, flags )
38{ 39{
39 40
40 settings = s; 41 settings = s;
41 m_replyid = ""; 42 m_replyid = "";
42 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 43 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
43 QStringList mails = con.emails(); 44 QStringList mails = con.emails();
44 QString defmail = con.preferredEmail(); 45 QString defmail = con.preferredEmail();
45 if ( mails.count() == 0) 46 if ( mails.count() == 0)
46 QMessageBox::information( 0, tr( "Hint" ), 47 QMessageBox::information( 0, tr( "Hint" ),
47 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 48 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
48 tr( "Ok" ) ); 49 tr( "Ok" ) );
49 if (defmail.length()!=0) { 50 if (defmail.length()!=0) {
50 fromBox->insertItem(defmail); 51 fromBox->insertItem(defmail);
51 } 52 }
52 QStringList::ConstIterator sit = mails.begin(); 53 QStringList::ConstIterator sit = mails.begin();
53 for (;sit!=mails.end();++sit) { 54 for (;sit!=mails.end();++sit) {
54 if ( (*sit)==defmail) 55 if ( (*sit)==defmail)
55 continue; 56 continue;
56 fromBox->insertItem((*sit)); 57 fromBox->insertItem((*sit));
57 } 58 }
58 senderNameEdit->setText(con.formattedName()); 59 senderNameEdit->setText(con.formattedName());
59 Config cfg( "mail" ); 60 Config cfg( "mail" );
60 cfg.setGroup( "Compose" ); 61 cfg.setGroup( "Compose" );
61 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 62 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
62 63
63 attList->addColumn( tr( "Name" ) ); 64 attList->addColumn( tr( "Name" ) );
64 attList->addColumn( tr( "Size" ) ); 65 attList->addColumn( tr( "Size" ) );
65 66
66 QList<Account> accounts = settings->getAccounts(); 67 QList<Account> accounts = settings->getAccounts();
67 68
68 Account *it; 69 Account *it;
69 for ( it = accounts.first(); it; it = accounts.next() ) { 70 for ( it = accounts.first(); it; it = accounts.next() ) {
70 if ( it->getType()==MAILLIB::A_SMTP ) { 71 if ( it->getType()==MAILLIB::A_SMTP ) {
71 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 72 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
72 smtpAccountBox->insertItem( smtp->getAccountName() ); 73 smtpAccountBox->insertItem( smtp->getAccountName() );
73 smtpAccounts.append( smtp ); 74 smtpAccounts.append( smtp );
74 } 75 }
75 } 76 }
76 if ( smtpAccounts.count() > 0 ) { 77 if ( smtpAccounts.count() > 0 ) {
77 fillValues( smtpAccountBox->currentItem() ); 78 fillValues( smtpAccountBox->currentItem() );
78 } else { 79 } else {
79 QMessageBox::information( 0, tr( "Problem" ), 80 QMessageBox::information( 0, tr( "Problem" ),
80 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), 81 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ),
81 tr( "Ok" ) ); 82 tr( "Ok" ) );
82 return; 83 return;
83 } 84 }
84 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 85 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
85 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 86 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
86 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 87 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
87 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 88 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
88 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 89 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
89 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 90 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
90 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 91 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
91 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 92 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
92 mMail = 0; 93 mMail = 0;
93 warnAttach = true; 94 warnAttach = true;
94 95
95} 96}
96void ComposeMail::saveAsDraft() 97void ComposeMail::saveAsDraft()
97{ 98{
98 99
99 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 100 Opie::Core::OSmartPointer<Mail> mail= new Mail();
100 mail->setMail(fromBox->currentText()); 101 mail->setMail(fromBox->currentText());
101 mail->setTo( toLine->text() ); 102 mail->setTo( toLine->text() );
102 mail->setName(senderNameEdit->text()); 103 mail->setName(senderNameEdit->text());
103 mail->setCC( ccLine->text() ); 104 mail->setCC( ccLine->text() );
104 mail->setBCC( bccLine->text() ); 105 mail->setBCC( bccLine->text() );
105 mail->setReply( replyLine->text() ); 106 mail->setReply( replyLine->text() );
106 mail->setSubject( subjectLine->text() ); 107 mail->setSubject( subjectLine->text() );
107 if (!m_replyid.isEmpty()) { 108 if (!m_replyid.isEmpty()) {
108 QStringList ids; 109 QStringList ids;
109 ids.append(m_replyid); 110 ids.append(m_replyid);
110 mail->setInreply(ids); 111 mail->setInreply(ids);
111 } 112 }
112 QString txt = message->text(); 113 QString txt = message->text();
113 if ( !sigMultiLine->text().isEmpty() ) { 114 if ( !sigMultiLine->text().isEmpty() ) {
114 txt.append( "\n--\n" ); 115 txt.append( "\n--\n" );
115 txt.append( sigMultiLine->text() ); 116 txt.append( sigMultiLine->text() );
116 } 117 }
117 mail->setMessage( txt ); 118 mail->setMessage( txt );
118 119
119 /* only use the default drafts folder name! */ 120 /* only use the default drafts folder name! */
120 Storemail wrapper(AbstractMail::draftFolder()); 121 Storemail wrapper(AbstractMail::draftFolder());
121 wrapper.storeMail(mail); 122 wrapper.storeMail(mail);
122 123
123 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 124 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
124 /* attachments we will ignore! */ 125 /* attachments we will ignore! */
125 if ( it != 0 ) { 126 if ( it != 0 ) {
126 if ( warnAttach ) 127 if ( warnAttach )
127 QMessageBox::warning(0,tr("Store message"), 128 QMessageBox::warning(0,tr("Store message"),
128 tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); 129 tr("<center>Attachments will not be stored in \"Draft\" folder</center>"));
129 warnAttach = false; 130 warnAttach = false;
130 } 131 }
131 setStatus( tr("Mail saved as draft!") ); 132 setStatus( tr("Mail saved as draft!") );
132} 133}
133void ComposeMail::clearStatus() 134void ComposeMail::clearStatus()
134{ 135{
135 topLevelWidget()->setCaption( tr("Compose mail") ); 136 topLevelWidget()->setCaption( tr("Compose mail") );
136} 137}
137void ComposeMail::setStatus( QString status ) 138void ComposeMail::setStatus( QString status )
138{ 139{
139 topLevelWidget()->setCaption( status ); 140 topLevelWidget()->setCaption( status );
140 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 141 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
141} 142}
142void ComposeMail::pickAddress( QLineEdit *line ) 143void ComposeMail::pickAddress( QLineEdit *line )
143{ 144{
144 //qDebug(" ComposeMail::pickAddress "); 145 //qDebug(" ComposeMail::pickAddress ");
145 QString names ;//= AddressPicker::getNames(); 146 QString names ;//= AddressPicker::getNames();
146 147
147 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 148 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
148 uint i=0; 149 uint i=0;
149 for (i=0; i < list.count(); i++) { 150 for (i=0; i < list.count(); i++) {
150 if ( !list[i].preferredEmail().isEmpty()) { 151 if ( !list[i].preferredEmail().isEmpty()) {
151 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 152 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
152 if ( i < list.count() -1 ) 153 if ( i < list.count() -1 )
153 names+= ","; 154 names+= ",";
154 } 155 }
155 } 156 }
156 157
157 158
158 if ( line->text().isEmpty() ) { 159 if ( line->text().isEmpty() ) {
159 line->setText( names ); 160 line->setText( names );
160 } else if ( !names.isEmpty() ) { 161 } else if ( !names.isEmpty() ) {
161 line->setText( line->text() + ", " + names ); 162 line->setText( line->text() + ", " + names );
162 } 163 }
163} 164}
164 165
165 166
166void ComposeMail::setTo( const QString & to ) 167void ComposeMail::setTo( const QString & to )
167{ 168{
168 toLine->setText( to ); 169 toLine->setText( to );
169} 170}
170 171
171void ComposeMail::setSubject( const QString & subject ) 172void ComposeMail::setSubject( const QString & subject )
172{ 173{
173 subjectLine->setText( subject ); 174 subjectLine->setText( subject );
174} 175}
175 176
176void ComposeMail::setInReplyTo( const QString & messageId ) 177void ComposeMail::setInReplyTo( const QString & messageId )
177{ 178{
178 m_replyid = messageId; 179 m_replyid = messageId;
179} 180}
180 181
181void ComposeMail::setMessage( const QString & text ) 182void ComposeMail::setMessage( const QString & text )
182{ 183{
183 message->setText( text ); 184 message->setText( text );
184} 185}
185 186
186 187
187void ComposeMail::pickAddressTo() 188void ComposeMail::pickAddressTo()
188{ 189{
189 pickAddress( toLine ); 190 pickAddress( toLine );
190} 191}
191 192
192void ComposeMail::pickAddressCC() 193void ComposeMail::pickAddressCC()
193{ 194{
194 pickAddress( ccLine ); 195 pickAddress( ccLine );
195} 196}
196 197
197void ComposeMail::pickAddressBCC() 198void ComposeMail::pickAddressBCC()
198{ 199{
199 pickAddress( bccLine ); 200 pickAddress( bccLine );
200} 201}
201 202
202void ComposeMail::pickAddressReply() 203void ComposeMail::pickAddressReply()
203{ 204{
204 pickAddress( replyLine ); 205 pickAddress( replyLine );
205} 206}
206 207
207void ComposeMail::fillValues( int ) 208void ComposeMail::fillValues( int )
208{ 209{
209#if 0 210#if 0
210 SMTPaccount *smtp = smtpAccounts.at( current ); 211 SMTPaccount *smtp = smtpAccounts.at( current );
211 ccLine->clear(); 212 ccLine->clear();
212 if ( smtp->getUseCC() ) { 213 if ( smtp->getUseCC() ) {
213 ccLine->setText( smtp->getCC() ); 214 ccLine->setText( smtp->getCC() );
214 } 215 }
215 bccLine->clear(); 216 bccLine->clear();
216 if ( smtp->getUseBCC() ) { 217 if ( smtp->getUseBCC() ) {
217 bccLine->setText( smtp->getBCC() ); 218 bccLine->setText( smtp->getBCC() );
218 } 219 }
219 replyLine->clear(); 220 replyLine->clear();
220 if ( smtp->getUseReply() ) { 221 if ( smtp->getUseReply() ) {
221 replyLine->setText( smtp->getReply() ); 222 replyLine->setText( smtp->getReply() );
222 } 223 }
223 sigMultiLine->setText( smtp->getSignature() ); 224 sigMultiLine->setText( smtp->getSignature() );
224#endif 225#endif
225} 226}
226 227
227void ComposeMail::slotAdjustColumns() 228void ComposeMail::slotAdjustColumns()
228{ 229{
229 int currPage = tabWidget->currentPageIndex(); 230 int currPage = tabWidget->currentPageIndex();
230 231
231 tabWidget->showPage( attachTab ); 232 tabWidget->showPage( attachTab );
232 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 233 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
233 attList->setColumnWidth( 1, 80 ); 234 attList->setColumnWidth( 1, 80 );
234 235
235 tabWidget->setCurrentPage( currPage ); 236 tabWidget->setCurrentPage( currPage );
236} 237}
237 238
238void ComposeMail::addAttachment() 239void ComposeMail::addAttachment()
239{ 240{
240 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 241 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
241 if ( !lnk.isEmpty() ) { 242 if ( !lnk.isEmpty() ) {
242 Attachment *att = new Attachment( lnk ); 243 Attachment *att = new Attachment( lnk );
243 (void) new AttachViewItem( attList, att ); 244 (void) new AttachViewItem( attList, att );
244 } 245 }
245} 246}
246 247
247void ComposeMail::removeAttachment() 248void ComposeMail::removeAttachment()
248{ 249{
249 if ( !attList->currentItem() ) { 250 if ( !attList->currentItem() ) {
250 QMessageBox::information( this, tr( "Error" ), 251 QMessageBox::information( this, tr( "Error" ),
251 tr( "<p>Please select a File.</p>" ), 252 tr( "<p>Please select a File.</p>" ),
252 tr( "Ok" ) ); 253 tr( "Ok" ) );
253 } else { 254 } else {
254 attList->takeItem( attList->currentItem() ); 255 attList->takeItem( attList->currentItem() );
255 } 256 }
256} 257}
257 258
258void ComposeMail::accept() 259void ComposeMail::accept()
259{ 260{
260 if ( smtpAccountBox->count() == 0 ) { 261 if ( smtpAccountBox->count() == 0 ) {
261 262
262 reject(); 263 reject();
263 return; 264 return;
264 } 265 }
265 266
266 if (! checkBoxLater->isChecked() ) { 267 if (! checkBoxLater->isChecked() ) {
267 int yesno = QMessageBox::warning(0,tr("Stop editing message"), 268 int yesno = QMessageBox::warning(0,tr("Stop editing message"),
268 tr("Send this message?"), 269 tr("Send this message?"),
269 tr("Yes"), 270 tr("Yes"),
270 tr("Cancel")); 271 tr("Cancel"));
271 272
272 if (yesno == 1) { 273 if (yesno == 1) {
273 return; 274 return;
274 } 275 }
275 } 276 }
276#if 0 277#if 0
277 odebug << "Sending Mail with " 278 odebug << "Sending Mail with "
278 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 279 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
279#endif 280#endif
280 Opie::Core::OSmartPointer<Mail> mail=new Mail; 281 Opie::Core::OSmartPointer<Mail> mail=new Mail;
281 282
282 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 283 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
283 mail->setMail(fromBox->currentText()); 284 mail->setMail(fromBox->currentText());
284 285
285 if ( !toLine->text().isEmpty() ) { 286 if ( !toLine->text().isEmpty() ) {
286 mail->setTo( toLine->text() ); 287 mail->setTo( toLine->text() );
287 } else { 288 } else {
288 QMessageBox::warning(0,tr("Sending mail"), 289 QMessageBox::warning(0,tr("Sending mail"),
289 tr("No Receiver spezified" ) ); 290 tr("No Receiver spezified" ) );
290 return; 291 return;
291 } 292 }
292 293
293 mail->setName(senderNameEdit->text()); 294 mail->setName(senderNameEdit->text());
294 mail->setCC( ccLine->text() ); 295 mail->setCC( ccLine->text() );
295 mail->setBCC( bccLine->text() ); 296 mail->setBCC( bccLine->text() );
296 mail->setReply( replyLine->text() ); 297 mail->setReply( replyLine->text() );
297 mail->setSubject( subjectLine->text() ); 298 mail->setSubject( subjectLine->text() );
298 if (!m_replyid.isEmpty()) { 299 if (!m_replyid.isEmpty()) {
299 QStringList ids; 300 QStringList ids;
300 ids.append(m_replyid); 301 ids.append(m_replyid);
301 mail->setInreply(ids); 302 mail->setInreply(ids);
302 } 303 }
303 QString txt = message->text(); 304 QString txt = message->text();
304 if ( !sigMultiLine->text().isEmpty() ) { 305 if ( !sigMultiLine->text().isEmpty() ) {
305 txt.append( "\n--\n" ); 306 txt.append( "\n--\n" );
306 txt.append( sigMultiLine->text() ); 307 txt.append( sigMultiLine->text() );
307 } 308 }
308 mail->setMessage( txt ); 309 mail->setMessage( txt );
309 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 310 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
310 while ( it != 0 ) { 311 while ( it != 0 ) {
311 mail->addAttachment( it->getAttachment() ); 312 mail->addAttachment( it->getAttachment() );
312 it = (AttachViewItem *) it->nextSibling(); 313 it = (AttachViewItem *) it->nextSibling();
313 } 314 }
314 315
315 SMTPwrapper wrapper( smtp ); 316 SMTPwrapper wrapper( smtp );
316 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 317 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
317 setStatus( tr ("Mail sent")); 318 setStatus( tr ("Mail sent"));
318 else { 319 else {
319 setStatus( tr ("Error: Something went wrong. Nothing sent")); 320 setStatus( tr ("Error: Something went wrong. Nothing sent"));
320 return; 321 return;
321 } 322 }
322 323
323 324
324 QDialog::accept(); 325 QDialog::accept();
325} 326}
326 327
327void ComposeMail::reject() 328void ComposeMail::reject()
328{ 329{
329 //qDebug("ComposeMail::reject() "); 330 //qDebug("ComposeMail::reject() ");
330 int yesno = QMessageBox::warning(0,tr("Store message?"), 331 int yesno = QMessageBox::warning(0,tr("Store message?"),
331 tr("Store message into drafts?\n"), 332 tr("Store message into drafts?\n"),
332 tr("Yes"), 333 tr("Yes"),
333 tr("No")); 334 tr("No"));
334 335
335 //qDebug("button %d ", yesno); 336 //qDebug("button %d ", yesno);
336 if (yesno == 0) { 337 if (yesno == 0) {
337 if ( toLine->text().isEmpty() ) { 338 if ( toLine->text().isEmpty() ) {
338 QMessageBox::warning(0,tr("Sending mail"), 339 QMessageBox::warning(0,tr("Sending mail"),
339 tr("No Receiver spezified" ) ); 340 tr("No Receiver spezified" ) );
340 return; 341 return;
341 } 342 }
342 saveAsDraft(); 343 saveAsDraft();
343 } 344 }
344 if (yesno == 2) { 345 if (yesno == 2) {
345 qDebug("return "); 346 qDebug("return ");
346 return; 347 return;
347 } 348 }
348 QDialog::reject(); 349 QDialog::reject();
349} 350}
350 351
351ComposeMail::~ComposeMail() 352ComposeMail::~ComposeMail()
352{ 353{
353} 354}
354 355
355void ComposeMail::reEditMail(const RecMailP&current) 356void ComposeMail::reEditMail(const RecMailP&current)
356{ 357{
357 RecMailP data = current; 358 RecMailP data = current;
358 message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); 359 message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
359 subjectLine->setText( data->getSubject()); 360 subjectLine->setText( data->getSubject());
360 toLine->setText(data->To().join(",")); 361 toLine->setText(data->To().join(","));
361 ccLine->setText(data->CC().join(",")); 362 ccLine->setText(data->CC().join(","));
362 bccLine->setText(data->Bcc().join(",")); 363 bccLine->setText(data->Bcc().join(","));
363 replyLine->setText(data->Replyto()); 364 replyLine->setText(data->Replyto());
364} 365}
365 366
366AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 367AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
367 : QListViewItem( parent ) 368 : QListViewItem( parent )
368{ 369{
369 attachment = att; 370 attachment = att;
370 if ( !attachment->getPixmap().isNull() ) 371 if ( !attachment->getPixmap().isNull() )
371 setPixmap( 0,attachment->getPixmap() ); 372 setPixmap( 0,attachment->getPixmap() );
372 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 373 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
373 setText( 1, QString::number( att->getSize() ) ); 374 setText( 1, QString::number( att->getSize() ) );
374} 375}
375 376
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp
index 1ca0ada..b92b0cf 100644
--- a/kmicromail/mailistviewitem.cpp
+++ b/kmicromail/mailistviewitem.cpp
@@ -1,142 +1,143 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1#include "mailistviewitem.h" 2#include "mailistviewitem.h"
2#include <libmailwrapper/abstractmail.h> 3#include <libmailwrapper/abstractmail.h>
3#include <qtextstream.h> 4#include <qtextstream.h>
4#include <kiconloader.h> 5#include <kiconloader.h>
5//#include <qpe/resource.h> 6//#include <qpe/resource.h>
6 7
7MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 8MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
8 :QListViewItem(parent,item),mail_data() 9 :QListViewItem(parent,item),mail_data()
9{ 10{
10} 11}
11 12
12void MailListViewItem::showEntry() 13void MailListViewItem::showEntry()
13{ 14{
14 if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { 15 if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) {
15 setPixmap( 0, SmallIcon ( "kmmsgreplied") ); 16 setPixmap( 0, SmallIcon ( "kmmsgreplied") );
16 } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { 17 } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) {
17 /* I think it looks nicer if there are not such a log of icons but only on mails 18 /* I think it looks nicer if there are not such a log of icons but only on mails
18 replied or new - Alwin*/ 19 replied or new - Alwin*/
19 //setPixmap( 0,SmallIcon ("kmmsgunseen") ); 20 //setPixmap( 0,SmallIcon ("kmmsgunseen") );
20 } else { 21 } else {
21 setPixmap( 0,SmallIcon ( "kmmsgnew") ); 22 setPixmap( 0,SmallIcon ( "kmmsgnew") );
22 } 23 }
23 double s = mail_data->Msgsize(); 24 double s = mail_data->Msgsize();
24 int w = 0; 25 int w = 0;
25 s/=1024; 26 s/=1024;
26 if (s>999.0) { 27 if (s>999.0) {
27 s/=1024.0; 28 s/=1024.0;
28 ++w; 29 ++w;
29 } 30 }
30 QString fsort; 31 QString fsort;
31 fsort.sprintf( "%.2f", s ); 32 fsort.sprintf( "%.2f", s );
32 QString fsize = QString::number( s, 'f', 2 ); 33 QString fsize = QString::number( s, 'f', 2 );
33 // 1.23 34 // 1.23
34 // 11.23 35 // 11.23
35 // 111.23 36 // 111.23
36 // 999.23 maxlen 37 // 999.23 maxlen
37 switch(fsize.length() ) { 38 switch(fsize.length() ) {
38 case 4: 39 case 4:
39 fsort = "00" + fsize ; 40 fsort = "00" + fsize ;
40 break; 41 break;
41 case 5: 42 case 5:
42 fsort = "0" + fsize ; 43 fsort = "0" + fsize ;
43 break; 44 break;
44 default: 45 default:
45 fsort = fsize ; 46 fsort = fsize ;
46 break; 47 break;
47 48
48 } 49 }
49 if ( w == 0 ) { 50 if ( w == 0 ) {
50 setText(3, fsize + "kB" ); 51 setText(3, fsize + "kB" );
51 mKeyMap.insert(3, "k" + fsort); 52 mKeyMap.insert(3, "k" + fsort);
52 //setText(3, "kB" + fsort ); // test only 53 //setText(3, "kB" + fsort ); // test only
53 } else { 54 } else {
54 //setText(3, fsize + "MB"); 55 //setText(3, fsize + "MB");
55 mKeyMap.insert(4, "M" +fsort ); 56 mKeyMap.insert(4, "M" +fsort );
56 } 57 }
57 setText(1,mail_data->getSubject()); 58 setText(1,mail_data->getSubject());
58 setText(2,mail_data->getFrom()); 59 setText(2,mail_data->getFrom());
59 60
60 QString date = mail_data->getDate(); 61 QString date = mail_data->getDate();
61 62
62 int kom = date.find( ",")+2; 63 int kom = date.find( ",")+2;
63 if ( kom == 1 ) 64 if ( kom == 1 )
64 kom = 0; 65 kom = 0;
65 if ( date.mid(kom,1) == " ") 66 if ( date.mid(kom,1) == " ")
66 ++kom; 67 ++kom;
67 if ( date.mid(kom+1,1) == " " ) 68 if ( date.mid(kom+1,1) == " " )
68 date = "0" + date.mid( kom ); 69 date = "0" + date.mid( kom );
69 else if ( kom ) 70 else if ( kom )
70 date = date.mid( kom ); 71 date = date.mid( kom );
71 if ( kom || date.mid(2,1 ) == " ") { 72 if ( kom || date.mid(2,1 ) == " ") {
72 QString mon = date.mid(3,3); 73 QString mon = date.mid(3,3);
73 QString so = 00; 74 QString so = 00;
74 if ( mon == "Jan" ) 75 if ( mon == "Jan" )
75 so = "01"; 76 so = "01";
76 else if ( mon == "Feb" ) 77 else if ( mon == "Feb" )
77 so = "02"; 78 so = "02";
78 else if ( mon == "Mar" ) 79 else if ( mon == "Mar" )
79 so = "03"; 80 so = "03";
80 else if ( mon == "Apr" ) 81 else if ( mon == "Apr" )
81 so = "04"; 82 so = "04";
82 else if ( mon == "May" ) 83 else if ( mon == "May" )
83 so = "05"; 84 so = "05";
84 else if ( mon == "Jun" ) 85 else if ( mon == "Jun" )
85 so = "06"; 86 so = "06";
86 else if ( mon == "Jul" ) 87 else if ( mon == "Jul" )
87 so = "07"; 88 so = "07";
88 else if ( mon == "Aug" ) 89 else if ( mon == "Aug" )
89 so = "08"; 90 so = "08";
90 else if ( mon == "Sep" ) 91 else if ( mon == "Sep" )
91 so = "09"; 92 so = "09";
92 else if ( mon == "Oct" ) 93 else if ( mon == "Oct" )
93 so = "10"; 94 so = "10";
94 else if ( mon == "Nov" ) 95 else if ( mon == "Nov" )
95 so = "11"; 96 so = "11";
96 else if ( mon == "Dec" ) 97 else if ( mon == "Dec" )
97 so = "12"; 98 so = "12";
98 date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); 99 date = date.mid(7,4)+so+date.left(2)+date.mid(12,14);
99 } 100 }
100 // if ( date.left(1) != "1" || date.left(1) != "2" ) 101 // if ( date.left(1) != "1" || date.left(1) != "2" )
101 // date = date.mid(5); 102 // date = date.mid(5);
102 mKeyMap.insert(4,date); 103 mKeyMap.insert(4,date);
103 setText(4,mail_data->getDate()); 104 setText(4,mail_data->getDate());
104} 105}
105 106
106void MailListViewItem::storeData(const RecMailP&data) 107void MailListViewItem::storeData(const RecMailP&data)
107{ 108{
108 mail_data = data; 109 mail_data = data;
109} 110}
110void MailListViewItem::setSortKey(int column,const QString &key) 111void MailListViewItem::setSortKey(int column,const QString &key)
111{ 112{
112 mKeyMap.insert(column,key); 113 mKeyMap.insert(column,key);
113} 114}
114QString MailListViewItem::key(int column, bool) const 115QString MailListViewItem::key(int column, bool) const
115{ 116{
116 // to make is fast, we use here special cases 117 // to make is fast, we use here special cases
117 if ( column == 3 || column == 4 ) { 118 if ( column == 3 || column == 4 ) {
118 return *mKeyMap.find(column); 119 return *mKeyMap.find(column);
119 } 120 }
120 if ( column == 1 ) { 121 if ( column == 1 ) {
121 if ( text(1).left(4).lower() == "re: " ) 122 if ( text(1).left(4).lower() == "re: " )
122 return text(1).mid(4); 123 return text(1).mid(4);
123 124
124 } 125 }
125 return text(column); 126 return text(column);
126 /* 127 /*
127 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 128 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
128 if (it == mKeyMap.end()) return text(column); 129 if (it == mKeyMap.end()) return text(column);
129 else return *it; 130 else return *it;
130 */ 131 */
131} 132}
132 133
133const RecMailP& MailListViewItem::data()const 134const RecMailP& MailListViewItem::data()const
134{ 135{
135 return mail_data; 136 return mail_data;
136} 137}
137 138
138MAILLIB::ATYPE MailListViewItem::wrapperType() 139MAILLIB::ATYPE MailListViewItem::wrapperType()
139{ 140{
140 if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; 141 if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED;
141 return mail_data->Wrapper()->getType(); 142 return mail_data->Wrapper()->getType();
142} 143}
diff --git a/kmicromail/mailistviewitem.h b/kmicromail/mailistviewitem.h
index cf8040b..0fd44d3 100644
--- a/kmicromail/mailistviewitem.h
+++ b/kmicromail/mailistviewitem.h
@@ -1,26 +1,27 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1#ifndef __MAILLISTVIEWITEM_H 2#ifndef __MAILLISTVIEWITEM_H
2#define __MAILLISTVIEWITEM_H 3#define __MAILLISTVIEWITEM_H
3 4
4#include <qlistview.h> 5#include <qlistview.h>
5#include <libmailwrapper/mailtypes.h> 6#include <libmailwrapper/mailtypes.h>
6#include <libmailwrapper/maildefines.h> 7#include <libmailwrapper/maildefines.h>
7 8
8class MailListViewItem:public QListViewItem 9class MailListViewItem:public QListViewItem
9{ 10{
10public: 11public:
11 MailListViewItem(QListView * parent, MailListViewItem * after ); 12 MailListViewItem(QListView * parent, MailListViewItem * after );
12 virtual ~MailListViewItem(){} 13 virtual ~MailListViewItem(){}
13 14
14 void storeData(const RecMailP&data); 15 void storeData(const RecMailP&data);
15 const RecMailP&data()const; 16 const RecMailP&data()const;
16 void showEntry(); 17 void showEntry();
17 MAILLIB::ATYPE wrapperType(); 18 MAILLIB::ATYPE wrapperType();
18 QString key(int column, bool) const; 19 QString key(int column, bool) const;
19 void setSortKey(int column,const QString &key); 20 void setSortKey(int column,const QString &key);
20protected: 21protected:
21 RecMailP mail_data; 22 RecMailP mail_data;
22 private: 23 private:
23 QMap<int,QString> mKeyMap; 24 QMap<int,QString> mKeyMap;
24}; 25};
25 26
26#endif 27#endif
diff --git a/kmicromail/main.cpp b/kmicromail/main.cpp
index 8a093c6..22f1200 100644
--- a/kmicromail/main.cpp
+++ b/kmicromail/main.cpp
@@ -1,57 +1,58 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1 2
2#ifndef DESKTOP_VERSION 3#ifndef DESKTOP_VERSION
3#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
4#include <stdlib.h> 5#include <stdlib.h>
5#else 6#else
6#include <qapplication.h> 7#include <qapplication.h>
7#include <qstring.h> 8#include <qstring.h>
8#include <qwindowsstyle.h> 9#include <qwindowsstyle.h>
9#include <qplatinumstyle.h> 10#include <qplatinumstyle.h>
10#include <qsgistyle.h> 11#include <qsgistyle.h>
11#endif 12#endif
12#include "opiemail.h" 13#include "opiemail.h"
13#include <qdir.h> 14#include <qdir.h>
14#include <kstandarddirs.h> 15#include <kstandarddirs.h>
15#include <kglobal.h> 16#include <kglobal.h>
16#include <stdio.h> 17#include <stdio.h>
17#include "mainwindow.h" 18#include "mainwindow.h"
18 19
19using namespace Opie::Core; 20using namespace Opie::Core;
20int main( int argc, char **argv ) { 21int main( int argc, char **argv ) {
21 22
22#ifndef DESKTOP_VERSION 23#ifndef DESKTOP_VERSION
23 QPEApplication a( argc, argv ); 24 QPEApplication a( argc, argv );
24 a.setKeepRunning (); 25 a.setKeepRunning ();
25#else 26#else
26 QApplication a( argc, argv ); 27 QApplication a( argc, argv );
27 QApplication::setStyle( new QPlatinumStyle ()); 28 QApplication::setStyle( new QPlatinumStyle ());
28#endif 29#endif
29 30
30 KGlobal::setAppName( "kmicromail" ); 31 KGlobal::setAppName( "kmicromail" );
31 QString fileName ; 32 QString fileName ;
32#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
33 fileName = getenv("QPEDIR"); 34 fileName = getenv("QPEDIR");
34 if ( QApplication::desktop()->width() > 320 ) 35 if ( QApplication::desktop()->width() > 320 )
35 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/icons22/"); 36 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/icons22/");
36 else 37 else
37 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/"); 38 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/");
38#else 39#else
39 fileName = qApp->applicationDirPath () + "/kdepim/kmicromail/"; 40 fileName = qApp->applicationDirPath () + "/kdepim/kmicromail/";
40 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 41 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
41#endif 42#endif
42 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kmicromail"))); 43 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kmicromail")));
43 OpieMail mw; 44 OpieMail mw;
44#ifndef DESKTOP_VERSION 45#ifndef DESKTOP_VERSION
45 //qDebug("CONNECT "); 46 //qDebug("CONNECT ");
46 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&mw, SLOT(message( const QCString&, const QByteArray& ))); 47 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&mw, SLOT(message( const QCString&, const QByteArray& )));
47 a.showMainWidget(&mw ); 48 a.showMainWidget(&mw );
48#else 49#else
49 a.setMainWidget(&mw ); 50 a.setMainWidget(&mw );
50 mw.show(); 51 mw.show();
51 //m.resize( 800, 600 ); 52 //m.resize( 800, 600 );
52 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 53 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
53#endif 54#endif
54 int rv = a.exec(); 55 int rv = a.exec();
55 return rv; 56 return rv;
56 57
57} 58}
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index e020297..2de5b40 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -1,290 +1,292 @@
1
2// CHANGED 2004-08-06 Lutz Rogowski
1#include <qlabel.h> 3#include <qlabel.h>
2#include <qvbox.h> 4#include <qvbox.h>
3#include <qheader.h> 5#include <qheader.h>
4#include <qtimer.h> 6#include <qtimer.h>
5#include <qlayout.h> 7#include <qlayout.h>
6#include <kdialog.h> 8#include <kdialog.h>
7#include <kiconloader.h> 9#include <kiconloader.h>
8#include <kapplication.h> 10#include <kapplication.h>
9 11
10#ifndef DESKTOP_VERSION 12#ifndef DESKTOP_VERSION
11#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
12#endif 14#endif
13#include "defines.h" 15#include "defines.h"
14#include "mainwindow.h" 16#include "mainwindow.h"
15#include <KDGanttMinimizeSplitter.h> 17#include <KDGanttMinimizeSplitter.h>
16 18
17 19
18#include <kabc/stdaddressbook.h> 20#include <kabc/stdaddressbook.h>
19 21
20MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 22MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
21 : QMainWindow( parent, name ) //, flags ) 23 : QMainWindow( parent, name ) //, flags )
22{ 24{
23 setCaption( tr( "OpieMail/Pi" ) ); 25 setCaption( tr( "OpieMail/Pi" ) );
24 setToolBarsMovable( false ); 26 setToolBarsMovable( false );
25 KABC::StdAddressBook::self(); 27 KABC::StdAddressBook::self();
26 toolBar = new QToolBar( this ); 28 toolBar = new QToolBar( this );
27 menuBar = new QMenuBar( toolBar ); 29 menuBar = new QMenuBar( toolBar );
28 mailMenu = new QPopupMenu( menuBar ); 30 mailMenu = new QPopupMenu( menuBar );
29 menuBar->insertItem( tr( "Mail" ), mailMenu ); 31 menuBar->insertItem( tr( "Mail" ), mailMenu );
30 settingsMenu = new QPopupMenu( menuBar ); 32 settingsMenu = new QPopupMenu( menuBar );
31 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 33 menuBar->insertItem( tr( "Settings" ), settingsMenu );
32 34
33 addToolBar( toolBar ); 35 addToolBar( toolBar );
34 toolBar->setHorizontalStretchable( true ); 36 toolBar->setHorizontalStretchable( true );
35 37
36 38
37 39
38 composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"), 40 composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"),
39 0, 0, this ); 41 0, 0, this );
40 composeMail->addTo( toolBar ); 42 composeMail->addTo( toolBar );
41 composeMail->addTo( mailMenu ); 43 composeMail->addTo( mailMenu );
42 44
43 sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("sendqueued") , 45 sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("sendqueued") ,
44 0, 0, this ); 46 0, 0, this );
45 sendQueued->addTo( toolBar ); 47 sendQueued->addTo( toolBar );
46 sendQueued->addTo( mailMenu ); 48 sendQueued->addTo( mailMenu );
47 49
48 /* 50 /*
49 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 51 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
50 0, 0, this ); 52 0, 0, this );
51 syncFolders->addTo( toolBar ); 53 syncFolders->addTo( toolBar );
52 syncFolders->addTo( mailMenu ); 54 syncFolders->addTo( mailMenu );
53 */ 55 */
54 56
55 showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") , 57 showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") ,
56 0, 0, this, 0, true ); 58 0, 0, this, 0, true );
57 showFolders->addTo( toolBar ); 59 showFolders->addTo( toolBar );
58 showFolders->addTo( mailMenu ); 60 showFolders->addTo( mailMenu );
59 showFolders->setOn( true ); 61 showFolders->setOn( true );
60 connect(showFolders, SIGNAL( toggled(bool) ), 62 connect(showFolders, SIGNAL( toggled(bool) ),
61 SLOT( slotShowFolders(bool) ) ); 63 SLOT( slotShowFolders(bool) ) );
62 64
63 /* 65 /*
64 searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ), 66 searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ),
65 0, 0, this ); 67 0, 0, this );
66 searchMails->addTo( toolBar ); 68 searchMails->addTo( toolBar );
67 searchMails->addTo( mailMenu ); 69 searchMails->addTo( mailMenu );
68 */ 70 */
69 71
70 deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this); 72 deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this);
71 deleteMails->addTo( toolBar ); 73 deleteMails->addTo( toolBar );
72 deleteMails->addTo( mailMenu ); 74 deleteMails->addTo( mailMenu );
73 connect( deleteMails, SIGNAL( activated() ), 75 connect( deleteMails, SIGNAL( activated() ),
74 SLOT( slotDeleteMail() ) ); 76 SLOT( slotDeleteMail() ) );
75 77
76 editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") , 78 editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") ,
77 0, 0, this ); 79 0, 0, this );
78 editSettings->addTo( settingsMenu ); 80 editSettings->addTo( settingsMenu );
79 connect( editSettings, SIGNAL( activated() ), 81 connect( editSettings, SIGNAL( activated() ),
80 SLOT( slotEditSettings() ) ); 82 SLOT( slotEditSettings() ) );
81 editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") , 83 editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") ,
82 0, 0, this ); 84 0, 0, this );
83 editAccounts->addTo( settingsMenu ); 85 editAccounts->addTo( settingsMenu );
84 86
85 //setCentralWidget( view ); 87 //setCentralWidget( view );
86 88
87 QVBox* wrapperBox = new QVBox( this ); 89 QVBox* wrapperBox = new QVBox( this );
88 setCentralWidget( wrapperBox ); 90 setCentralWidget( wrapperBox );
89 91
90 // QWidget *view = new QWidget( wrapperBox ); 92 // QWidget *view = new QWidget( wrapperBox );
91 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 93 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
92 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 94 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
93 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 95 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
94 96
95 folderView = new AccountView( split ); 97 folderView = new AccountView( split );
96 folderView->header()->hide(); 98 folderView->header()->hide();
97 folderView->setRootIsDecorated( false ); 99 folderView->setRootIsDecorated( false );
98 folderView->addColumn( tr( "Mailbox" ) ); 100 folderView->addColumn( tr( "Mailbox" ) );
99 101
100 //layout->addWidget( folderView ); 102 //layout->addWidget( folderView );
101 103
102 mailView = new QListView( split ); 104 mailView = new QListView( split );
103 mailView->addColumn( tr( " " ) ); 105 mailView->addColumn( tr( " " ) );
104 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 106 mailView->addColumn( tr( "Subject" ),QListView::Manual );
105 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 107 mailView->addColumn( tr( "Sender" ),QListView::Manual );
106 mailView->addColumn( tr( "Size" ),QListView::Manual); 108 mailView->addColumn( tr( "Size" ),QListView::Manual);
107 mailView->addColumn( tr( "Date" ),QListView::Manual); 109 mailView->addColumn( tr( "Date" ),QListView::Manual);
108 mailView->setAllColumnsShowFocus(true); 110 mailView->setAllColumnsShowFocus(true);
109 //mailView->setSorting(-1); 111 //mailView->setSorting(-1);
110 mailView->setRootIsDecorated( false ); 112 mailView->setRootIsDecorated( false );
111 statusWidget = new StatusWidget( wrapperBox ); 113 statusWidget = new StatusWidget( wrapperBox );
112 statusWidget->hide(); 114 statusWidget->hide();
113 115
114 //layout->addWidget( mailView ); 116 //layout->addWidget( mailView );
115 //layout->setStretchFactor( folderView, 1 ); 117 //layout->setStretchFactor( folderView, 1 );
116 //layout->setStretchFactor( mailView, 2 ); 118 //layout->setStretchFactor( mailView, 2 );
117 119
118 slotAdjustLayout(); 120 slotAdjustLayout();
119#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
120 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 122 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
121 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 123 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
122#endif 124#endif
123 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, 125 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this,
124 SLOT( mailLeftClicked(QListViewItem*) ) ); 126 SLOT( mailLeftClicked(QListViewItem*) ) );
125 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, 127 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this,
126 SLOT( mailLeftClicked(QListViewItem*) ) ); 128 SLOT( mailLeftClicked(QListViewItem*) ) );
127 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 129 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
128 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 130 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
129 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 131 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
130 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 132 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
131 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 133 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
132 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 134 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
133// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 135// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
134 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 136 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
135 //mailView->setMultiSelection ( true ); 137 //mailView->setMultiSelection ( true );
136 mailView->setSelectionMode( QListView::Extended ); 138 mailView->setSelectionMode( QListView::Extended );
137 QValueList<int> list; 139 QValueList<int> list;
138 int fw = 100; 140 int fw = 100;
139 if ( QApplication::desktop()->width() > 320 ) 141 if ( QApplication::desktop()->width() > 320 )
140 fw = 50; 142 fw = 50;
141 list.append( fw ); 143 list.append( fw );
142 list.append( 100 ); 144 list.append( 100 );
143 split->setSizes( list ); 145 split->setSizes( list );
144 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 146 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
145 mailView->setShowSortIndicator ( true ); 147 mailView->setShowSortIndicator ( true );
146 QLabel *spacer = new QLabel( toolBar ); 148 QLabel *spacer = new QLabel( toolBar );
147 spacer->setBackgroundMode( QWidget::PaletteButton ); 149 spacer->setBackgroundMode( QWidget::PaletteButton );
148 toolBar->setStretchableWidget( spacer ); 150 toolBar->setStretchableWidget( spacer );
149 151
150 QAction* closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this); 152 QAction* closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this);
151 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 153 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
152 closeMail->addTo(toolBar); 154 closeMail->addTo(toolBar);
153 closeMail->addTo(mailMenu); 155 closeMail->addTo(mailMenu);
154 156
155 157
156 QPopupMenu* helpMenu = new QPopupMenu( menuBar ); 158 QPopupMenu* helpMenu = new QPopupMenu( menuBar );
157 menuBar->insertItem( tr( "Help" ), helpMenu ); 159 menuBar->insertItem( tr( "Help" ), helpMenu );
158 QAction* li = new QAction(tr("About"), QPixmap(), 0, 0, this); 160 QAction* li = new QAction(tr("About"), QPixmap(), 0, 0, this);
159 connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); 161 connect( li, SIGNAL( activated() ), SLOT( showAbout()) );
160 li->addTo(helpMenu); 162 li->addTo(helpMenu);
161 li = new QAction(tr("Licence"),QPixmap(), 0, 0, this); 163 li = new QAction(tr("Licence"),QPixmap(), 0, 0, this);
162 connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); 164 connect( li, SIGNAL( activated() ), SLOT( showLicence()) );
163 li->addTo(helpMenu); 165 li->addTo(helpMenu);
164 li = new QAction(tr("LibEtPan Licence"), QPixmap(), 0, 0, this); 166 li = new QAction(tr("LibEtPan Licence"), QPixmap(), 0, 0, this);
165 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); 167 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
166 li->addTo(helpMenu); 168 li->addTo(helpMenu);
167} 169}
168 170
169MainWindow::~MainWindow() 171MainWindow::~MainWindow()
170{ 172{
171} 173}
172 174
173void MainWindow::showLicence() 175void MainWindow::showLicence()
174{ 176{
175 KApplication::showLicence(); 177 KApplication::showLicence();
176} 178}
177void MainWindow::showAbout() 179void MainWindow::showAbout()
178{ 180{
179 QString version; 181 QString version;
180#include <../version> 182#include <../version>
181 183
182 QString cap = "About KOpieMail/Pi"; 184 QString cap = "About KOpieMail/Pi";
183 QString text =i18n("KOpieMail/Platform-independent\n") + 185 QString text =i18n("KOpieMail/Platform-independent\n") +
184 "(OM/Pi) " + version + " - " 186 "(OM/Pi) " + version + " - "
185 187
186#ifdef DESKTOP_VERSION 188#ifdef DESKTOP_VERSION
187 "Desktop Edition\n" 189 "Desktop Edition\n"
188#else 190#else
189 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" 191 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n"
190#endif 192#endif
191 "www.pi-sync.net\n\n" 193 "www.pi-sync.net\n\n"
192 194
193 195
194 196
195"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" 197"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n"
196 "KOpieMail/Pi is based on Opie Mail\n" 198 "KOpieMail/Pi is based on Opie Mail\n"
197 "Copyright (c) Rajko Albrecht and the Opie team\n" 199 "Copyright (c) Rajko Albrecht and the Opie team\n"
198 "KOpieMail/Pi is licensed under the GPL\n" 200 "KOpieMail/Pi is licensed under the GPL\n"
199 "\n" 201 "\n"
200 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" 202 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n"
201 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" 203 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n"
202 "libEtPan has its own licence - see LibEtPan licence\n"; 204 "libEtPan has its own licence - see LibEtPan licence\n";
203 205
204 KApplication::showText( cap, text ); 206 KApplication::showText( cap, text );
205} 207}
206void MainWindow::showEtpanLicence() 208void MainWindow::showEtpanLicence()
207{ 209{
208 KApplication::showFile( "LibEtPan licence", "kdepim/kmicromail/COPYRIGHTlibetpan" ); 210 KApplication::showFile( "LibEtPan licence", "kdepim/kmicromail/COPYRIGHTlibetpan" );
209 211
210} 212}
211void MainWindow::appMessage(const QCString &, const QByteArray &) 213void MainWindow::appMessage(const QCString &, const QByteArray &)
212{ 214{
213 qDebug("appMessage implemented by subclass"); 215 qDebug("appMessage implemented by subclass");
214} 216}
215 217
216void MainWindow::slotAdjustLayout() { 218void MainWindow::slotAdjustLayout() {
217 219
218 /* 220 /*
219 QWidget *d = QApplication::desktop(); 221 QWidget *d = QApplication::desktop();
220 222
221 if ( d->width() < d->height() ) { 223 if ( d->width() < d->height() ) {
222 layout->setDirection( QBoxLayout::TopToBottom ); 224 layout->setDirection( QBoxLayout::TopToBottom );
223 } else { 225 } else {
224 layout->setDirection( QBoxLayout::LeftToRight ); 226 layout->setDirection( QBoxLayout::LeftToRight );
225 } 227 }
226 */ 228 */
227} 229}
228 230
229void MainWindow::slotAdjustColumns() 231void MainWindow::slotAdjustColumns()
230{ 232{
231 bool hidden = folderView->isHidden(); 233 bool hidden = folderView->isHidden();
232 if ( hidden ) folderView->show(); 234 if ( hidden ) folderView->show();
233 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 235 folderView->setColumnWidth( 0, folderView->visibleWidth() );
234 if ( hidden ) folderView->hide(); 236 if ( hidden ) folderView->hide();
235 237
236 mailView->setColumnWidth( 0, 10 ); 238 mailView->setColumnWidth( 0, 10 );
237 mailView->setColumnWidth( 1, 100 ); 239 mailView->setColumnWidth( 1, 100 );
238 mailView->setColumnWidth( 2, 100 ); 240 mailView->setColumnWidth( 2, 100 );
239 mailView->setColumnWidth( 3, 50 ); 241 mailView->setColumnWidth( 3, 50 );
240 mailView->setColumnWidth( 4, 120 ); 242 mailView->setColumnWidth( 4, 120 );
241} 243}
242 244
243void MainWindow::slotEditSettings() 245void MainWindow::slotEditSettings()
244{ 246{
245} 247}
246 248
247void MainWindow::slotShowFolders( bool ) 249void MainWindow::slotShowFolders( bool )
248{ 250{
249 qDebug("not implemented: "); 251 qDebug("not implemented: ");
250} 252}
251 253
252void MainWindow::refreshMailView(const QValueList<RecMailP>&) 254void MainWindow::refreshMailView(const QValueList<RecMailP>&)
253{ 255{
254 qDebug("not implemented: "); 256 qDebug("not implemented: ");
255} 257}
256 258
257void MainWindow::mailLeftClicked(QListViewItem * ) 259void MainWindow::mailLeftClicked(QListViewItem * )
258{ 260{
259 qDebug("not implemented: "); 261 qDebug("not implemented: ");
260} 262}
261 263
262void MainWindow::displayMail() 264void MainWindow::displayMail()
263{ 265{
264 qDebug("not implemented: "); 266 qDebug("not implemented: ");
265} 267}
266 268
267void MainWindow::slotDeleteMail() 269void MainWindow::slotDeleteMail()
268{ 270{
269 qDebug("not implemented: "); 271 qDebug("not implemented: ");
270} 272}
271 273
272void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) 274void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
273{ 275{
274 qDebug("not implemented: "); 276 qDebug("not implemented: ");
275} 277}
276 278
277void MainWindow::slotSendQueued() 279void MainWindow::slotSendQueued()
278{ 280{
279 qDebug("not implemented: "); 281 qDebug("not implemented: ");
280} 282}
281 283
282void MainWindow::slotEditAccounts() 284void MainWindow::slotEditAccounts()
283{ 285{
284 qDebug("not implemented: "); 286 qDebug("not implemented: ");
285} 287}
286 288
287void MainWindow::slotComposeMail() 289void MainWindow::slotComposeMail()
288{ 290{
289 qDebug("not implemented: "); 291 qDebug("not implemented: ");
290} 292}
diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h
index d6dc6cc..f5b81aa 100644
--- a/kmicromail/mainwindow.h
+++ b/kmicromail/mainwindow.h
@@ -1,59 +1,61 @@
1
2// CHANGED 2004-08-06 Lutz Rogowski
1#ifndef MAINWINDOW_H 3#ifndef MAINWINDOW_H
2#define MAINWINDOW_H 4#define MAINWINDOW_H
3 5
4#include <qmainwindow.h> 6#include <qmainwindow.h>
5#include <qlistview.h> 7#include <qlistview.h>
6#include <qaction.h> 8#include <qaction.h>
7 9
8#include <qtoolbar.h> 10#include <qtoolbar.h>
9#include <qmenubar.h> 11#include <qmenubar.h>
10 12
11#include "accountview.h" 13#include "accountview.h"
12#include "statuswidget.h" 14#include "statuswidget.h"
13 15
14#include <libmailwrapper/mailtypes.h> 16#include <libmailwrapper/mailtypes.h>
15#include <opie2/osmartpointer.h> 17#include <opie2/osmartpointer.h>
16 18
17class RecMail; 19class RecMail;
18 20
19class MainWindow : public QMainWindow 21class MainWindow : public QMainWindow
20{ 22{
21 Q_OBJECT 23 Q_OBJECT
22 24
23public: 25public:
24 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 26 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
25 virtual ~MainWindow(); 27 virtual ~MainWindow();
26 28
27public slots: 29public slots:
28 virtual void slotAdjustColumns(); 30 virtual void slotAdjustColumns();
29 virtual void appMessage(const QCString &msg, const QByteArray &data); 31 virtual void appMessage(const QCString &msg, const QByteArray &data);
30 virtual void slotComposeMail(); 32 virtual void slotComposeMail();
31 33
32protected slots: 34protected slots:
33 virtual void slotSendQueued(); 35 virtual void slotSendQueued();
34 virtual void slotEditAccounts(); 36 virtual void slotEditAccounts();
35 virtual void slotShowFolders( bool show ); 37 virtual void slotShowFolders( bool show );
36 virtual void refreshMailView(const QValueList<RecMailP>&); 38 virtual void refreshMailView(const QValueList<RecMailP>&);
37 virtual void displayMail(); 39 virtual void displayMail();
38 virtual void slotDeleteMail(); 40 virtual void slotDeleteMail();
39 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 41 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
40 virtual void slotAdjustLayout(); 42 virtual void slotAdjustLayout();
41 virtual void slotEditSettings(); 43 virtual void slotEditSettings();
42 virtual void mailLeftClicked( QListViewItem * ); 44 virtual void mailLeftClicked( QListViewItem * );
43 void showLicence(); 45 void showLicence();
44 void showAbout(); 46 void showAbout();
45 void showEtpanLicence(); 47 void showEtpanLicence();
46 48
47protected: 49protected:
48 QToolBar *toolBar; 50 QToolBar *toolBar;
49 StatusWidget *statusWidget; 51 StatusWidget *statusWidget;
50 QMenuBar *menuBar; 52 QMenuBar *menuBar;
51 QPopupMenu *mailMenu, *settingsMenu; 53 QPopupMenu *mailMenu, *settingsMenu;
52 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, 54 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
53 *editSettings, *editAccounts, *syncFolders; 55 *editSettings, *editAccounts, *syncFolders;
54 AccountView *folderView; 56 AccountView *folderView;
55 QListView *mailView; 57 QListView *mailView;
56 //QBoxLayout *layout; 58 //QBoxLayout *layout;
57}; 59};
58 60
59#endif 61#endif
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 70fbcb2..d522ad0 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,363 +1,364 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1 2
2#include "settingsdialog.h" 3#include "settingsdialog.h"
3#include "opiemail.h" 4#include "opiemail.h"
4#include "editaccounts.h" 5#include "editaccounts.h"
5#include "composemail.h" 6#include "composemail.h"
6#include "mailistviewitem.h" 7#include "mailistviewitem.h"
7#include "viewmail.h" 8#include "viewmail.h"
8#include "selectstore.h" 9#include "selectstore.h"
9#include "selectsmtp.h" 10#include "selectsmtp.h"
10 11
11#include <qmessagebox.h> 12#include <qmessagebox.h>
12 13
13#include <qpe/qpeapplication.h> 14#include <qpe/qpeapplication.h>
14#include <libmailwrapper/smtpwrapper.h> 15#include <libmailwrapper/smtpwrapper.h>
15#include <libmailwrapper/mailtypes.h> 16#include <libmailwrapper/mailtypes.h>
16#include <libmailwrapper/abstractmail.h> 17#include <libmailwrapper/abstractmail.h>
17/* OPIE */ 18/* OPIE */
18//#include <qpe/resource.h> 19//#include <qpe/resource.h>
19#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
20 21
21/* QT */ 22/* QT */
22 23
23using namespace Opie::Core; 24using namespace Opie::Core;
24 25
25OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 26OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
26 : MainWindow( parent, name) //, WStyle_ContextHelp ) 27 : MainWindow( parent, name) //, WStyle_ContextHelp )
27{ 28{
28 settings = new Settings(); 29 settings = new Settings();
29 30
30 folderView->populate( settings->getAccounts() ); 31 folderView->populate( settings->getAccounts() );
31 32
32} 33}
33 34
34OpieMail::~OpieMail() 35OpieMail::~OpieMail()
35{ 36{
36 if (settings) delete settings; 37 if (settings) delete settings;
37} 38}
38 39
39void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 40void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
40{ 41{
41 42
42} 43}
43#include <stdlib.h> 44#include <stdlib.h>
44void OpieMail::message(const QCString &msg, const QByteArray &data) 45void OpieMail::message(const QCString &msg, const QByteArray &data)
45{ 46{
46 // copied from old mail2 47 // copied from old mail2
47 static int ii = 0; 48 static int ii = 0;
48 49
49 // block second call 50 // block second call
50 if ( ii < 2 ) { 51 if ( ii < 2 ) {
51 ++ii; 52 ++ii;
52 if ( ii > 1 ) { 53 if ( ii > 1 ) {
53 qDebug("qcop call blocked "); 54 qDebug("qcop call blocked ");
54 return; 55 return;
55 } 56 }
56 } 57 }
57 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 58 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
58 if (msg == "writeMail(QString,QString)") 59 if (msg == "writeMail(QString,QString)")
59 { 60 {
60 QDataStream stream(data,IO_ReadOnly); 61 QDataStream stream(data,IO_ReadOnly);
61 QString name, email; 62 QString name, email;
62 stream >> name >> email; 63 stream >> name >> email;
63 // removing the whitespaces at beginning and end is needed! 64 // removing the whitespaces at beginning and end is needed!
64 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 65 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
65 } 66 }
66 else if (msg == "newMail()") 67 else if (msg == "newMail()")
67 { 68 {
68 slotComposeMail(); 69 slotComposeMail();
69 } 70 }
70 else if (msg == "newMail(QString)") 71 else if (msg == "newMail(QString)")
71 { 72 {
72 QDataStream stream(data,IO_ReadOnly); 73 QDataStream stream(data,IO_ReadOnly);
73 QString nameemail; 74 QString nameemail;
74 stream >> nameemail; 75 stream >> nameemail;
75 // the format is 76 // the format is
76 // NAME <EMAIL>:SUBJECT 77 // NAME <EMAIL>:SUBJECT
77 //qDebug("message %s ", nameemail.latin1()); 78 //qDebug("message %s ", nameemail.latin1());
78 79
79 slotwriteMail2( nameemail ); 80 slotwriteMail2( nameemail );
80 } 81 }
81} 82}
82void OpieMail::slotwriteMail2(const QString& namemail ) 83void OpieMail::slotwriteMail2(const QString& namemail )
83{ 84{
84 // qDebug("OpieMail::slotwriteMail2 "); 85 // qDebug("OpieMail::slotwriteMail2 ");
85 qApp->processEvents(); 86 qApp->processEvents();
86 ComposeMail compose( settings, this, 0, true ); 87 ComposeMail compose( settings, this, 0, true );
87 if ( !namemail.isEmpty() ) { 88 if ( !namemail.isEmpty() ) {
88 QString to = namemail; 89 QString to = namemail;
89 if ( namemail.find( " <") > 1 ) { 90 if ( namemail.find( " <") > 1 ) {
90 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 91 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
91 } else 92 } else
92 if ( namemail.find( "<") > 1 ) { 93 if ( namemail.find( "<") > 1 ) {
93 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 94 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
94 } 95 }
95 int sub = to.find( ">:"); 96 int sub = to.find( ">:");
96 if ( sub > 0 ) { 97 if ( sub > 0 ) {
97 compose.setTo( to.left(sub+1) ); 98 compose.setTo( to.left(sub+1) );
98 compose.setSubject( to.mid(sub+2) ); 99 compose.setSubject( to.mid(sub+2) );
99 } else 100 } else
100 compose.setTo( to ); 101 compose.setTo( to );
101 } 102 }
102 compose.slotAdjustColumns(); 103 compose.slotAdjustColumns();
103 compose.showMaximized(); 104 compose.showMaximized();
104 compose.exec(); 105 compose.exec();
105 //qDebug("retttich "); 106 //qDebug("retttich ");
106} 107}
107void OpieMail::slotwriteMail(const QString&name,const QString&email) 108void OpieMail::slotwriteMail(const QString&name,const QString&email)
108{ 109{
109 // qDebug("OpieMail::slotwriteMail "); 110 // qDebug("OpieMail::slotwriteMail ");
110 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 111 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
111 if (!email.isEmpty()) 112 if (!email.isEmpty())
112 { 113 {
113 if (!name.isEmpty()) 114 if (!name.isEmpty())
114 { 115 {
115 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 116 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
116 } 117 }
117 else 118 else
118 { 119 {
119 compose.setTo(email); 120 compose.setTo(email);
120 } 121 }
121 } 122 }
122 compose.slotAdjustColumns(); 123 compose.slotAdjustColumns();
123 compose.showMaximized(); 124 compose.showMaximized();
124 compose.exec(); 125 compose.exec();
125} 126}
126 127
127void OpieMail::slotComposeMail() 128void OpieMail::slotComposeMail()
128{ 129{
129 slotwriteMail2( QString () ); 130 slotwriteMail2( QString () );
130 //slotwriteMail(0l,0l); 131 //slotwriteMail(0l,0l);
131} 132}
132 133
133void OpieMail::slotSendQueued() 134void OpieMail::slotSendQueued()
134{ 135{
135 SMTPaccount *smtp = 0; 136 SMTPaccount *smtp = 0;
136 137
137 QList<Account> list = settings->getAccounts(); 138 QList<Account> list = settings->getAccounts();
138 QList<SMTPaccount> smtpList; 139 QList<SMTPaccount> smtpList;
139 smtpList.setAutoDelete(false); 140 smtpList.setAutoDelete(false);
140 Account *it; 141 Account *it;
141 for ( it = list.first(); it; it = list.next() ) 142 for ( it = list.first(); it; it = list.next() )
142 { 143 {
143 if ( it->getType() == MAILLIB::A_SMTP ) 144 if ( it->getType() == MAILLIB::A_SMTP )
144 { 145 {
145 smtp = static_cast<SMTPaccount *>(it); 146 smtp = static_cast<SMTPaccount *>(it);
146 smtpList.append(smtp); 147 smtpList.append(smtp);
147 } 148 }
148 } 149 }
149 if (smtpList.count()==0) 150 if (smtpList.count()==0)
150 { 151 {
151 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); 152 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n"));
152 return; 153 return;
153 } 154 }
154 if (smtpList.count()==1) 155 if (smtpList.count()==1)
155 { 156 {
156 smtp = smtpList.at(0); 157 smtp = smtpList.at(0);
157 } 158 }
158 else 159 else
159 { 160 {
160 smtp = 0; 161 smtp = 0;
161 selectsmtp selsmtp; 162 selectsmtp selsmtp;
162 selsmtp.setSelectionlist(&smtpList); 163 selsmtp.setSelectionlist(&smtpList);
163 selsmtp.showMaximized(); 164 selsmtp.showMaximized();
164 if ( selsmtp.exec() == QDialog::Accepted ) 165 if ( selsmtp.exec() == QDialog::Accepted )
165 { 166 {
166 smtp = selsmtp.selected_smtp(); 167 smtp = selsmtp.selected_smtp();
167 } 168 }
168 } 169 }
169 if (smtp) 170 if (smtp)
170 { 171 {
171 SMTPwrapper * wrap = new SMTPwrapper(smtp); 172 SMTPwrapper * wrap = new SMTPwrapper(smtp);
172 if ( wrap->flushOutbox() ) 173 if ( wrap->flushOutbox() )
173 { 174 {
174 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 175 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
175 } 176 }
176 delete wrap; 177 delete wrap;
177 } 178 }
178} 179}
179 180
180void OpieMail::slotSearchMails() 181void OpieMail::slotSearchMails()
181{ 182{
182 qDebug("OpieMail::slotSearchMails():not implemented "); 183 qDebug("OpieMail::slotSearchMails():not implemented ");
183} 184}
184 185
185void OpieMail::slotEditSettings() 186void OpieMail::slotEditSettings()
186{ 187{
187 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 188 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
188 settingsDialog.showMaximized(); 189 settingsDialog.showMaximized();
189 settingsDialog.exec(); 190 settingsDialog.exec();
190} 191}
191 192
192void OpieMail::slotEditAccounts() 193void OpieMail::slotEditAccounts()
193{ 194{
194 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 195 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
195 eaDialog.slotAdjustColumns(); 196 eaDialog.slotAdjustColumns();
196 eaDialog.showMaximized(); 197 eaDialog.showMaximized();
197 eaDialog.exec(); 198 eaDialog.exec();
198 if ( settings ) delete settings; 199 if ( settings ) delete settings;
199 settings = new Settings(); 200 settings = new Settings();
200 201
201 folderView->populate( settings->getAccounts() ); 202 folderView->populate( settings->getAccounts() );
202} 203}
203 204
204void OpieMail::displayMail() 205void OpieMail::displayMail()
205{ 206{
206 QListViewItem*item = mailView->currentItem(); 207 QListViewItem*item = mailView->currentItem();
207 if (!item) return; 208 if (!item) return;
208 RecMailP mail = ((MailListViewItem*)item)->data(); 209 RecMailP mail = ((MailListViewItem*)item)->data();
209 RecBodyP body = folderView->fetchBody(mail); 210 RecBodyP body = folderView->fetchBody(mail);
210 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 211 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
211 readMail.setBody( body ); 212 readMail.setBody( body );
212 readMail.setMail( mail ); 213 readMail.setMail( mail );
213 readMail.showMaximized(); 214 readMail.showMaximized();
214 readMail.exec(); 215 readMail.exec();
215 216
216 if ( readMail.deleted ) 217 if ( readMail.deleted )
217 { 218 {
218 folderView->refreshCurrent(); 219 folderView->refreshCurrent();
219 } 220 }
220 else 221 else
221 { 222 {
222 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 223 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
223 } 224 }
224} 225}
225 226
226void OpieMail::slotDeleteMail() 227void OpieMail::slotDeleteMail()
227{ 228{
228 if (!mailView->currentItem()) return; 229 if (!mailView->currentItem()) return;
229 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 230 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
230 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 231 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
231 { 232 {
232 mail->Wrapper()->deleteMail( mail ); 233 mail->Wrapper()->deleteMail( mail );
233 folderView->refreshCurrent(); 234 folderView->refreshCurrent();
234 } 235 }
235} 236}
236void OpieMail::slotDeleteAllMail() 237void OpieMail::slotDeleteAllMail()
237{ 238{
238 if (!mailView->currentItem()) return; 239 if (!mailView->currentItem()) return;
239 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 240 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
240 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 241 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
241 { 242 {
242 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 243 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
243 while ( item ) { 244 while ( item ) {
244 if ( item->isSelected() ) { 245 if ( item->isSelected() ) {
245 RecMailP mail = item->data(); 246 RecMailP mail = item->data();
246 mail->Wrapper()->deleteMail( mail ); 247 mail->Wrapper()->deleteMail( mail );
247 } 248 }
248 item = (MailListViewItem*)item->nextSibling(); 249 item = (MailListViewItem*)item->nextSibling();
249 } 250 }
250 folderView->refreshCurrent(); 251 folderView->refreshCurrent();
251 } 252 }
252} 253}
253void OpieMail::clearSelection() 254void OpieMail::clearSelection()
254{ 255{
255 mailView->clearSelection(); 256 mailView->clearSelection();
256 257
257} 258}
258 259
259void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 260void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
260{ 261{
261 if (!mailView->currentItem()) return; 262 if (!mailView->currentItem()) return;
262 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 263 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
263 /* just the RIGHT button - or hold on pda */ 264 /* just the RIGHT button - or hold on pda */
264 if (button!=2) {return;} 265 if (button!=2) {return;}
265 if (!item) return; 266 if (!item) return;
266 QPopupMenu *m = new QPopupMenu(0); 267 QPopupMenu *m = new QPopupMenu(0);
267 if (m) 268 if (m)
268 { 269 {
269 if (mailtype==MAILLIB::A_NNTP) { 270 if (mailtype==MAILLIB::A_NNTP) {
270 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 271 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
271// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 272// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
272 } else { 273 } else {
273 if (folderView->currentisDraft()) { 274 if (folderView->currentisDraft()) {
274 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 275 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
275 } 276 }
276 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 277 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
277 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 278 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
278 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 279 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
279 m->insertSeparator(); 280 m->insertSeparator();
280 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 281 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
281 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); 282 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
282 } 283 }
283 m->setFocus(); 284 m->setFocus();
284 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 285 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
285 delete m; 286 delete m;
286 } 287 }
287} 288}
288 289
289void OpieMail::slotShowFolders( bool show ) 290void OpieMail::slotShowFolders( bool show )
290{ 291{
291 if ( show && folderView->isHidden() ) 292 if ( show && folderView->isHidden() )
292 { 293 {
293 folderView->show(); 294 folderView->show();
294 } 295 }
295 else if ( !show && !folderView->isHidden() ) 296 else if ( !show && !folderView->isHidden() )
296 { 297 {
297 folderView->hide(); 298 folderView->hide();
298 } 299 }
299} 300}
300 301
301void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 302void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
302{ 303{
303 MailListViewItem*item = 0; 304 MailListViewItem*item = 0;
304 mailView->clear(); 305 mailView->clear();
305 306
306 QValueList<RecMailP>::ConstIterator it; 307 QValueList<RecMailP>::ConstIterator it;
307 for (it = list.begin(); it != list.end();++it) 308 for (it = list.begin(); it != list.end();++it)
308 { 309 {
309 item = new MailListViewItem(mailView,item); 310 item = new MailListViewItem(mailView,item);
310 item->storeData((*it)); 311 item->storeData((*it));
311 item->showEntry(); 312 item->showEntry();
312 } 313 }
313} 314}
314 315
315void OpieMail::mailLeftClicked( QListViewItem *item ) 316void OpieMail::mailLeftClicked( QListViewItem *item )
316{ 317{
317 mailView->clearSelection(); 318 mailView->clearSelection();
318 /* just LEFT button - or tap with stylus on pda */ 319 /* just LEFT button - or tap with stylus on pda */
319 //if (button!=1) return; 320 //if (button!=1) return;
320 if (!item) return; 321 if (!item) return;
321 if (folderView->currentisDraft()) { 322 if (folderView->currentisDraft()) {
322 reEditMail(); 323 reEditMail();
323 } else { 324 } else {
324 displayMail(); 325 displayMail();
325 } 326 }
326} 327}
327 328
328void OpieMail::slotMoveCopyMail() 329void OpieMail::slotMoveCopyMail()
329{ 330{
330 if (!mailView->currentItem()) return; 331 if (!mailView->currentItem()) return;
331 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 332 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
332 AbstractMail*targetMail = 0; 333 AbstractMail*targetMail = 0;
333 QString targetFolder = ""; 334 QString targetFolder = "";
334 Selectstore sels; 335 Selectstore sels;
335 folderView->setupFolderselect(&sels); 336 folderView->setupFolderselect(&sels);
336 if (!sels.exec()) return; 337 if (!sels.exec()) return;
337 targetMail = sels.currentMail(); 338 targetMail = sels.currentMail();
338 targetFolder = sels.currentFolder(); 339 targetFolder = sels.currentFolder();
339 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 340 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
340 targetFolder.isEmpty()) 341 targetFolder.isEmpty())
341 { 342 {
342 return; 343 return;
343 } 344 }
344 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 345 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
345 { 346 {
346 QMessageBox::critical(0,tr("Error creating new Folder"), 347 QMessageBox::critical(0,tr("Error creating new Folder"),
347 tr("<center>Error while creating<br>new folder - breaking.</center>")); 348 tr("<center>Error while creating<br>new folder - breaking.</center>"));
348 return; 349 return;
349 } 350 }
350 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 351 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
351 folderView->refreshCurrent(); 352 folderView->refreshCurrent();
352} 353}
353 354
354void OpieMail::reEditMail() 355void OpieMail::reEditMail()
355{ 356{
356 if (!mailView->currentItem()) return; 357 if (!mailView->currentItem()) return;
357 358
358 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 359 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
359 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 360 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
360 compose.slotAdjustColumns(); 361 compose.slotAdjustColumns();
361 compose.showMaximized(); 362 compose.showMaximized();
362 compose.exec(); 363 compose.exec();
363} 364}
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 703711d..67b77f8 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -1,526 +1,527 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1#include "composemail.h" 2#include "composemail.h"
2#include "viewmail.h" 3#include "viewmail.h"
3 4
4#include <libmailwrapper/settings.h> 5#include <libmailwrapper/settings.h>
5#include <libmailwrapper/abstractmail.h> 6#include <libmailwrapper/abstractmail.h>
6#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
7#include <kapplication.h> 8#include <kapplication.h>
8 9
9/* OPIE */ 10/* OPIE */
10//#include <opie2/odebug.h> 11//#include <opie2/odebug.h>
11//#include <opie2/ofiledialog.h> 12//#include <opie2/ofiledialog.h>
12//#include <opie2/oimagescrollview.h> 13//#include <opie2/oimagescrollview.h>
13 14
14#include <kfiledialog.h> 15#include <kfiledialog.h>
15#include <kdialog.h> 16#include <kdialog.h>
16 17
17#include <qpe/config.h> 18#include <qpe/config.h>
18#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
19 20
20/* QT */ 21/* QT */
21#include <qtextbrowser.h> 22#include <qtextbrowser.h>
22#include <qmessagebox.h> 23#include <qmessagebox.h>
23#include <qtextstream.h> 24#include <qtextstream.h>
24#include <qaction.h> 25#include <qaction.h>
25#include <qpopupmenu.h> 26#include <qpopupmenu.h>
26#include <qfile.h> 27#include <qfile.h>
27#include <qlayout.h> 28#include <qlayout.h>
28 29
29//using namespace Opie::Ui; 30//using namespace Opie::Ui;
30//using namespace Opie::Core; 31//using namespace Opie::Core;
31 32
32AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 33AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
33 const QString&fsize,int num,const QValueList<int>&path) 34 const QString&fsize,int num,const QValueList<int>&path)
34 : QListViewItem(parent,after),_partNum(num) 35 : QListViewItem(parent,after),_partNum(num)
35{ 36{
36 _path=path; 37 _path=path;
37 setText(0, mime); 38 setText(0, mime);
38 setText(1, desc); 39 setText(1, desc);
39 setText(2, file); 40 setText(2, file);
40 setText(3, fsize); 41 setText(3, fsize);
41} 42}
42 43
43AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 44AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
44 const QString&fsize,int num,const QValueList<int>&path) 45 const QString&fsize,int num,const QValueList<int>&path)
45 : QListViewItem(parent,after),_partNum(num) 46 : QListViewItem(parent,after),_partNum(num)
46{ 47{
47 _path=path; 48 _path=path;
48 setText(0, mime); 49 setText(0, mime);
49 setText(1, desc); 50 setText(1, desc);
50 setText(2, file); 51 setText(2, file);
51 setText(3, fsize); 52 setText(3, fsize);
52} 53}
53 54
54bool AttachItem::isParentof(const QValueList<int>&path) 55bool AttachItem::isParentof(const QValueList<int>&path)
55{ 56{
56 /* if not set, then no parent */ 57 /* if not set, then no parent */
57 if (path.count()==0||_path.count()==0) return false; 58 if (path.count()==0||_path.count()==0) return false;
58 /* the parent must have one digit less then a child */ 59 /* the parent must have one digit less then a child */
59 if (path.count()!=_path.count()+1) return false; 60 if (path.count()!=_path.count()+1) return false;
60 for (unsigned int i=0; i < _path.count();++i) 61 for (unsigned int i=0; i < _path.count();++i)
61 { 62 {
62 if (_path[i]!=path[i]) return false; 63 if (_path[i]!=path[i]) return false;
63 } 64 }
64 return true; 65 return true;
65} 66}
66 67
67AttachItem* ViewMail::searchParent(const QValueList<int>&path) 68AttachItem* ViewMail::searchParent(const QValueList<int>&path)
68{ 69{
69 QListViewItemIterator it( attachments ); 70 QListViewItemIterator it( attachments );
70 for ( ; it.current(); ++it ) 71 for ( ; it.current(); ++it )
71 { 72 {
72 AttachItem*ati = (AttachItem*)it.current(); 73 AttachItem*ati = (AttachItem*)it.current();
73 if (ati->isParentof(path)) return ati; 74 if (ati->isParentof(path)) return ati;
74 } 75 }
75 return 0; 76 return 0;
76} 77}
77 78
78AttachItem* ViewMail::lastChild(AttachItem*parent) 79AttachItem* ViewMail::lastChild(AttachItem*parent)
79{ 80{
80 if (!parent) return 0; 81 if (!parent) return 0;
81 AttachItem* item = (AttachItem*)parent->firstChild(); 82 AttachItem* item = (AttachItem*)parent->firstChild();
82 if (!item) return item; 83 if (!item) return item;
83 AttachItem*temp=0; 84 AttachItem*temp=0;
84 while( (temp=(AttachItem*)item->nextSibling())) 85 while( (temp=(AttachItem*)item->nextSibling()))
85 { 86 {
86 item = temp; 87 item = temp;
87 } 88 }
88 return item; 89 return item;
89} 90}
90 91
91void ViewMail::setBody(const RecBodyP&body ) 92void ViewMail::setBody(const RecBodyP&body )
92{ 93{
93 94
94 m_body = body; 95 m_body = body;
95 m_mail[2] = body->Bodytext(); 96 m_mail[2] = body->Bodytext();
96 attachbutton->setEnabled(body->Parts().count()>0); 97 attachbutton->setEnabled(body->Parts().count()>0);
97 attachments->setEnabled(body->Parts().count()>0); 98 attachments->setEnabled(body->Parts().count()>0);
98 if (body->Parts().count()==0) 99 if (body->Parts().count()==0)
99 { 100 {
100 return; 101 return;
101 } 102 }
102 AttachItem * curItem=0; 103 AttachItem * curItem=0;
103 AttachItem * parentItem = 0; 104 AttachItem * parentItem = 0;
104 QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); 105 QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
105 QString desc,fsize; 106 QString desc,fsize;
106 double s = body->Description()->Size(); 107 double s = body->Description()->Size();
107 int w; 108 int w;
108 w=0; 109 w=0;
109 110
110 while (s>1024) 111 while (s>1024)
111 { 112 {
112 s/=1024; 113 s/=1024;
113 ++w; 114 ++w;
114 if (w>=2) break; 115 if (w>=2) break;
115 } 116 }
116 117
117 QString q=""; 118 QString q="";
118 switch(w) 119 switch(w)
119 { 120 {
120 case 1: 121 case 1:
121 q="k"; 122 q="k";
122 break; 123 break;
123 case 2: 124 case 2:
124 q="M"; 125 q="M";
125 break; 126 break;
126 default: 127 default:
127 break; 128 break;
128 } 129 }
129 130
130 { 131 {
131 /* I did not found a method to make a CONTENT reset on a QTextStream 132 /* I did not found a method to make a CONTENT reset on a QTextStream
132 so I use this construct that the stream will re-constructed in each 133 so I use this construct that the stream will re-constructed in each
133 loop. To let it work, the textstream is packed into a own area of 134 loop. To let it work, the textstream is packed into a own area of
134 code is it will be destructed after finishing its small job. 135 code is it will be destructed after finishing its small job.
135 */ 136 */
136 QTextOStream o(&fsize); 137 QTextOStream o(&fsize);
137 if (w>0) o.precision(2); else o.precision(0); 138 if (w>0) o.precision(2); else o.precision(0);
138 o.setf(QTextStream::fixed); 139 o.setf(QTextStream::fixed);
139 o << s << " " << q << "Byte"; 140 o << s << " " << q << "Byte";
140 } 141 }
141 142
142 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); 143 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
143 QString filename = ""; 144 QString filename = "";
144 145
145 for (unsigned int i = 0; i < body->Parts().count();++i) 146 for (unsigned int i = 0; i < body->Parts().count();++i)
146 { 147 {
147 filename = ""; 148 filename = "";
148 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); 149 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype();
149 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); 150 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin();
150 for (;it!=body->Parts()[i]->Parameters().end();++it) 151 for (;it!=body->Parts()[i]->Parameters().end();++it)
151 { 152 {
152 if (it.key().lower()=="name") 153 if (it.key().lower()=="name")
153 { 154 {
154 filename=it.data(); 155 filename=it.data();
155 } 156 }
156 } 157 }
157 s = body->Parts()[i]->Size(); 158 s = body->Parts()[i]->Size();
158 w = 0; 159 w = 0;
159 while (s>1024) 160 while (s>1024)
160 { 161 {
161 s/=1024; 162 s/=1024;
162 ++w; 163 ++w;
163 if (w>=2) break; 164 if (w>=2) break;
164 } 165 }
165 switch(w) 166 switch(w)
166 { 167 {
167 case 1: 168 case 1:
168 q="k"; 169 q="k";
169 break; 170 break;
170 case 2: 171 case 2:
171 q="M"; 172 q="M";
172 break; 173 break;
173 default: 174 default:
174 q=""; 175 q="";
175 break; 176 break;
176 } 177 }
177 QTextOStream o(&fsize); 178 QTextOStream o(&fsize);
178 if (w>0) o.precision(2); else o.precision(0); 179 if (w>0) o.precision(2); else o.precision(0);
179 o.setf(QTextStream::fixed); 180 o.setf(QTextStream::fixed);
180 o << s << " " << q << "Byte"; 181 o << s << " " << q << "Byte";
181 desc = body->Parts()[i]->Description(); 182 desc = body->Parts()[i]->Description();
182 parentItem = searchParent(body->Parts()[i]->Positionlist()); 183 parentItem = searchParent(body->Parts()[i]->Positionlist());
183 if (parentItem) 184 if (parentItem)
184 { 185 {
185 AttachItem*temp = lastChild(parentItem); 186 AttachItem*temp = lastChild(parentItem);
186 if (temp) curItem = temp; 187 if (temp) curItem = temp;
187 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 188 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
188 attachments->setRootIsDecorated(true); 189 attachments->setRootIsDecorated(true);
189 curItem = parentItem; 190 curItem = parentItem;
190 } 191 }
191 else 192 else
192 { 193 {
193 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 194 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
194 } 195 }
195 } 196 }
196} 197}
197 198
198 199
199void ViewMail::slotShowHtml( bool state ) 200void ViewMail::slotShowHtml( bool state )
200{ 201{
201 m_showHtml = state; 202 m_showHtml = state;
202 setText(); 203 setText();
203} 204}
204 205
205void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 206void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
206{ 207{
207 if (!item ) 208 if (!item )
208 return; 209 return;
209 210
210 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 211 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
211 { 212 {
212 setText(); 213 setText();
213 return; 214 return;
214 } 215 }
215 QPopupMenu *menu = new QPopupMenu(); 216 QPopupMenu *menu = new QPopupMenu();
216 int ret=0; 217 int ret=0;
217 218
218 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 219 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
219 { 220 {
220 menu->insertItem( tr( "Show Text" ), 1 ); 221 menu->insertItem( tr( "Show Text" ), 1 );
221 } 222 }
222 if (item->text(0).left(6)=="image/") { 223 if (item->text(0).left(6)=="image/") {
223 menu->insertItem(tr("Display image preview"),2); 224 menu->insertItem(tr("Display image preview"),2);
224 } 225 }
225 menu->insertItem( tr( "Save Attachment" ), 0 ); 226 menu->insertItem( tr( "Save Attachment" ), 0 );
226 menu->insertSeparator(1); 227 menu->insertSeparator(1);
227 228
228 ret = menu->exec( point, 0 ); 229 ret = menu->exec( point, 0 );
229 230
230 switch(ret) 231 switch(ret)
231 { 232 {
232 case 0: 233 case 0:
233 { 234 {
234 //MimeTypes types; 235 //MimeTypes types;
235 //types.insert( "all", "*" ); 236 //types.insert( "all", "*" );
236 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); 237 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this );
237 238
238 if( !str.isEmpty() ) 239 if( !str.isEmpty() )
239 { 240 {
240 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 241 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
241 if (content) 242 if (content)
242 { 243 {
243 QFile output(str); 244 QFile output(str);
244 output.open(IO_WriteOnly); 245 output.open(IO_WriteOnly);
245 output.writeBlock(content->Content(),content->Length()); 246 output.writeBlock(content->Content(),content->Length());
246 output.close(); 247 output.close();
247 delete content; 248 delete content;
248 } 249 }
249 } 250 }
250 } 251 }
251 break ; 252 break ;
252 253
253 case 2: 254 case 2:
254 { 255 {
255 QString tmpfile = "/tmp/opiemail-image"; 256 QString tmpfile = "/tmp/opiemail-image";
256 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 257 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
257 if (content) { 258 if (content) {
258 QFile output(tmpfile); 259 QFile output(tmpfile);
259 output.open(IO_WriteOnly); 260 output.open(IO_WriteOnly);
260 output.writeBlock(content->Content(),content->Length()); 261 output.writeBlock(content->Content(),content->Length());
261 output.close(); 262 output.close();
262 delete content; 263 delete content;
263 MailImageDlg iview(""); 264 MailImageDlg iview("");
264 iview.setName(tmpfile); 265 iview.setName(tmpfile);
265 KApplication::execDialog(&iview); 266 KApplication::execDialog(&iview);
266 output.remove(); 267 output.remove();
267 } 268 }
268 } 269 }
269 break; 270 break;
270 case 1: 271 case 1:
271 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 272 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
272 { 273 {
273 setText(); 274 setText();
274 } 275 }
275 else 276 else
276 { 277 {
277 if ( m_recMail->Wrapper() != 0l ) 278 if ( m_recMail->Wrapper() != 0l )
278 { // make sure that there is a wrapper , even after delete or simular actions 279 { // make sure that there is a wrapper , even after delete or simular actions
279 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 280 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
280 } 281 }
281 } 282 }
282 break; 283 break;
283 } 284 }
284 delete menu; 285 delete menu;
285} 286}
286 287
287 288
288void ViewMail::setMail(const RecMailP&mail ) 289void ViewMail::setMail(const RecMailP&mail )
289{ 290{
290 291
291 m_recMail = mail; 292 m_recMail = mail;
292 293
293 m_mail[0] = mail->getFrom(); 294 m_mail[0] = mail->getFrom();
294 m_mail[1] = mail->getSubject(); 295 m_mail[1] = mail->getSubject();
295 m_mail[3] = mail->getDate(); 296 m_mail[3] = mail->getDate();
296 m_mail[4] = mail->Msgid(); 297 m_mail[4] = mail->Msgid();
297 298
298 m_mail2[0] = mail->To(); 299 m_mail2[0] = mail->To();
299 m_mail2[1] = mail->CC(); 300 m_mail2[1] = mail->CC();
300 m_mail2[2] = mail->Bcc(); 301 m_mail2[2] = mail->Bcc();
301 302
302 setText(); 303 setText();
303} 304}
304 305
305 306
306 307
307ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 308ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
308 : ViewMailBase(parent, name, fl), _inLoop(false) 309 : ViewMailBase(parent, name, fl), _inLoop(false)
309{ 310{
310 m_gotBody = false; 311 m_gotBody = false;
311 deleted = false; 312 deleted = false;
312 313
313 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 314 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
314 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 315 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
315 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 316 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
316 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 317 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
317 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 318 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
318 319
319 attachments->setEnabled(m_gotBody); 320 attachments->setEnabled(m_gotBody);
320 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 321 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
321 322
322 readConfig(); 323 readConfig();
323 attachments->setSorting(-1); 324 attachments->setSorting(-1);
324} 325}
325 326
326void ViewMail::readConfig() 327void ViewMail::readConfig()
327{ 328{
328 Config cfg( "mail" ); 329 Config cfg( "mail" );
329 cfg.setGroup( "Settings" ); 330 cfg.setGroup( "Settings" );
330 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 331 m_showHtml = cfg.readBoolEntry( "showHtml", false );
331 showHtml->setOn( m_showHtml ); 332 showHtml->setOn( m_showHtml );
332} 333}
333 334
334void ViewMail::setText() 335void ViewMail::setText()
335{ 336{
336 337
337 QString toString; 338 QString toString;
338 QString ccString; 339 QString ccString;
339 QString bccString; 340 QString bccString;
340 341
341 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 342 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
342 { 343 {
343 toString += (*it); 344 toString += (*it);
344 } 345 }
345 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 346 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
346 { 347 {
347 ccString += (*it); 348 ccString += (*it);
348 } 349 }
349 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 350 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
350 { 351 {
351 bccString += (*it); 352 bccString += (*it);
352 } 353 }
353 354
354 setCaption( tr("E-Mail by %1").arg( m_mail[0] ) ); 355 setCaption( tr("E-Mail by %1").arg( m_mail[0] ) );
355 356
356 m_mailHtml = "<html><body>" 357 m_mailHtml = "<html><body>"
357 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 358 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
358 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 359 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
359 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 360 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
360 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 361 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
361 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 362 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
362 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 363 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
363 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 364 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
364 "</td></tr></table><font face=fixed>"; 365 "</td></tr></table><font face=fixed>";
365 366
366 if ( !m_showHtml ) 367 if ( !m_showHtml )
367 { 368 {
368 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 369 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
369 } 370 }
370 else 371 else
371 { 372 {
372 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 373 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
373 } 374 }
374 // remove later in favor of a real handling 375 // remove later in favor of a real handling
375 m_gotBody = true; 376 m_gotBody = true;
376} 377}
377 378
378 379
379ViewMail::~ViewMail() 380ViewMail::~ViewMail()
380{ 381{
381 m_recMail->Wrapper()->cleanMimeCache(); 382 m_recMail->Wrapper()->cleanMimeCache();
382 hide(); 383 hide();
383} 384}
384 385
385void ViewMail::hide() 386void ViewMail::hide()
386{ 387{
387 QWidget::hide(); 388 QWidget::hide();
388 389
389 if (_inLoop) 390 if (_inLoop)
390 { 391 {
391 _inLoop = false; 392 _inLoop = false;
392 qApp->exit_loop(); 393 qApp->exit_loop();
393 394
394 } 395 }
395 396
396} 397}
397 398
398void ViewMail::exec() 399void ViewMail::exec()
399{ 400{
400 show(); 401 show();
401 402
402 if (!_inLoop) 403 if (!_inLoop)
403 { 404 {
404 _inLoop = true; 405 _inLoop = true;
405 qApp->enter_loop(); 406 qApp->enter_loop();
406 } 407 }
407 408
408} 409}
409 410
410QString ViewMail::deHtml(const QString &string) 411QString ViewMail::deHtml(const QString &string)
411{ 412{
412 QString string_ = string; 413 QString string_ = string;
413 string_.replace(QRegExp("&"), "&amp;"); 414 string_.replace(QRegExp("&"), "&amp;");
414 string_.replace(QRegExp("<"), "&lt;"); 415 string_.replace(QRegExp("<"), "&lt;");
415 string_.replace(QRegExp(">"), "&gt;"); 416 string_.replace(QRegExp(">"), "&gt;");
416 string_.replace(QRegExp("\\n"), "<br>"); 417 string_.replace(QRegExp("\\n"), "<br>");
417 return string_; 418 return string_;
418} 419}
419 420
420void ViewMail::slotReply() 421void ViewMail::slotReply()
421{ 422{
422 if (!m_gotBody) 423 if (!m_gotBody)
423 { 424 {
424 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 425 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
425 return; 426 return;
426 } 427 }
427 428
428 QString rtext; 429 QString rtext;
429 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 430 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
430 .arg( m_mail[0] ) 431 .arg( m_mail[0] )
431 .arg( m_mail[3] ); 432 .arg( m_mail[3] );
432 433
433 QString text = m_mail[2]; 434 QString text = m_mail[2];
434 QStringList lines = QStringList::split(QRegExp("\\n"), text); 435 QStringList lines = QStringList::split(QRegExp("\\n"), text);
435 QStringList::Iterator it; 436 QStringList::Iterator it;
436 for (it = lines.begin(); it != lines.end(); it++) 437 for (it = lines.begin(); it != lines.end(); it++)
437 { 438 {
438 rtext += "> " + *it + "\n"; 439 rtext += "> " + *it + "\n";
439 } 440 }
440 rtext += "\n"; 441 rtext += "\n";
441 442
442 QString prefix; 443 QString prefix;
443 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; 444 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = "";
444 else prefix = "Re: "; // no i18n on purpose 445 else prefix = "Re: "; // no i18n on purpose
445 446
446 Settings *settings = new Settings(); 447 Settings *settings = new Settings();
447 ComposeMail composer( settings ,this, 0, true); 448 ComposeMail composer( settings ,this, 0, true);
448 if (m_recMail->Replyto().isEmpty()) { 449 if (m_recMail->Replyto().isEmpty()) {
449 composer.setTo( m_recMail->getFrom()); 450 composer.setTo( m_recMail->getFrom());
450 } else { 451 } else {
451 composer.setTo( m_recMail->Replyto()); 452 composer.setTo( m_recMail->Replyto());
452 } 453 }
453 composer.setSubject( prefix + m_mail[1] ); 454 composer.setSubject( prefix + m_mail[1] );
454 composer.setMessage( rtext ); 455 composer.setMessage( rtext );
455 composer.setInReplyTo(m_recMail->Msgid()); 456 composer.setInReplyTo(m_recMail->Msgid());
456 457
457 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 458 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
458 { 459 {
459 m_recMail->Wrapper()->answeredMail(m_recMail); 460 m_recMail->Wrapper()->answeredMail(m_recMail);
460 } 461 }
461} 462}
462 463
463void ViewMail::slotForward() 464void ViewMail::slotForward()
464{ 465{
465 if (!m_gotBody) 466 if (!m_gotBody)
466 { 467 {
467 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 468 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
468 return; 469 return;
469 } 470 }
470 471
471 QString ftext; 472 QString ftext;
472 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 473 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
473 .arg( m_mail[0] ); 474 .arg( m_mail[0] );
474 if (!m_mail[3].isNull()) 475 if (!m_mail[3].isNull())
475 ftext += QString("Date: %1\n") 476 ftext += QString("Date: %1\n")
476 .arg( m_mail[3] ); 477 .arg( m_mail[3] );
477 if (!m_mail[0].isNull()) 478 if (!m_mail[0].isNull())
478 ftext += QString("From: %1\n") 479 ftext += QString("From: %1\n")
479 .arg( m_mail[0] ); 480 .arg( m_mail[0] );
480 if (!m_mail[1].isNull()) 481 if (!m_mail[1].isNull())
481 ftext += QString("Subject: %1\n") 482 ftext += QString("Subject: %1\n")
482 .arg( m_mail[1] ); 483 .arg( m_mail[1] );
483 484
484 ftext += QString("\n%1\n") 485 ftext += QString("\n%1\n")
485 .arg( m_mail[2]); 486 .arg( m_mail[2]);
486 487
487 ftext += QString("----- End forwarded message -----\n"); 488 ftext += QString("----- End forwarded message -----\n");
488 489
489 Settings *settings = new Settings(); 490 Settings *settings = new Settings();
490 ComposeMail composer( settings ,this, 0, true); 491 ComposeMail composer( settings ,this, 0, true);
491 composer.setSubject( "Fwd: " + m_mail[1] ); 492 composer.setSubject( "Fwd: " + m_mail[1] );
492 composer.setMessage( ftext ); 493 composer.setMessage( ftext );
493 if ( QDialog::Accepted == KApplication::execDialog( &composer )) 494 if ( QDialog::Accepted == KApplication::execDialog( &composer ))
494 { 495 {
495 } 496 }
496} 497}
497 498
498void ViewMail::slotDeleteMail( ) 499void ViewMail::slotDeleteMail( )
499{ 500{
500 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 501 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
501 { 502 {
502 m_recMail->Wrapper()->deleteMail( m_recMail ); 503 m_recMail->Wrapper()->deleteMail( m_recMail );
503 hide(); 504 hide();
504 deleted = true; 505 deleted = true;
505 } 506 }
506} 507}
507 508
508MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) 509MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f)
509 : KDialog(parent,name,modal) 510 : KDialog(parent,name,modal)
510{ 511{
511 QVBoxLayout*dlglayout = new QVBoxLayout(this); 512 QVBoxLayout*dlglayout = new QVBoxLayout(this);
512 dlglayout->setSpacing(2); 513 dlglayout->setSpacing(2);
513 dlglayout->setMargin(1); 514 dlglayout->setMargin(1);
514 //m_imageview = new Opie::MM::OImageScrollView(this); 515 //m_imageview = new Opie::MM::OImageScrollView(this);
515 //dlglayout->addWidget(m_imageview); 516 //dlglayout->addWidget(m_imageview);
516} 517}
517 518
518MailImageDlg::~MailImageDlg() 519MailImageDlg::~MailImageDlg()
519{ 520{
520} 521}
521 522
522void MailImageDlg::setName(const QString&fname) 523void MailImageDlg::setName(const QString&fname)
523{ 524{
524 qDebug("viewmail.cpp: MailImageDlg::setName Pending"); 525 qDebug("viewmail.cpp: MailImageDlg::setName Pending");
525 // m_imageview->setImage(fname); 526 // m_imageview->setImage(fname);
526} 527}
diff --git a/kmicromail/viewmailbase.cpp b/kmicromail/viewmailbase.cpp
index 584a0ac..705b57f 100644
--- a/kmicromail/viewmailbase.cpp
+++ b/kmicromail/viewmailbase.cpp
@@ -1,91 +1,92 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1#include <qtextbrowser.h> 2#include <qtextbrowser.h>
2#include <qlistview.h> 3#include <qlistview.h>
3#include <qaction.h> 4#include <qaction.h>
4#include <qlabel.h> 5#include <qlabel.h>
5#include <qvbox.h> 6#include <qvbox.h>
6 7
7#include <qtoolbar.h> 8#include <qtoolbar.h>
8#include <qmenubar.h> 9#include <qmenubar.h>
9#include <kiconloader.h> 10#include <kiconloader.h>
10//#include <qpe/resource.h> 11//#include <qpe/resource.h>
11 12
12#include "viewmailbase.h" 13#include "viewmailbase.h"
13//#include "opendiag.h" 14//#include "opendiag.h"
14 15
15ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) 16ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
16 : QMainWindow(parent, name, fl) 17 : QMainWindow(parent, name, fl)
17{ 18{
18 19
19 setToolBarsMovable(false); 20 setToolBarsMovable(false);
20 21
21 toolbar = new QToolBar(this); 22 toolbar = new QToolBar(this);
22 menubar = new QMenuBar( toolbar ); 23 menubar = new QMenuBar( toolbar );
23 mailmenu = new QPopupMenu( menubar ); 24 mailmenu = new QPopupMenu( menubar );
24 menubar->insertItem( tr( "Mail" ), mailmenu ); 25 menubar->insertItem( tr( "Mail" ), mailmenu );
25 26
26 toolbar->setHorizontalStretchable(true); 27 toolbar->setHorizontalStretchable(true);
27 addToolBar(toolbar); 28 addToolBar(toolbar);
28 29
29 reply = new QAction(tr("Reply"),SmallIcon("reply"), 0, 0, this); 30 reply = new QAction(tr("Reply"),SmallIcon("reply"), 0, 0, this);
30 reply->addTo(toolbar); 31 reply->addTo(toolbar);
31 reply->addTo(mailmenu); 32 reply->addTo(mailmenu);
32 33
33 forward = new QAction(tr("Forward"),SmallIcon("forward"), 0, 0, this); 34 forward = new QAction(tr("Forward"),SmallIcon("forward"), 0, 0, this);
34 forward->addTo(toolbar); 35 forward->addTo(toolbar);
35 forward->addTo(mailmenu); 36 forward->addTo(mailmenu);
36 37
37 attachbutton = new QAction(tr("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); 38 attachbutton = new QAction(tr("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true);
38 attachbutton->addTo(toolbar); 39 attachbutton->addTo(toolbar);
39 attachbutton->addTo(mailmenu); 40 attachbutton->addTo(mailmenu);
40 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); 41 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
41 42
42 43
43 showHtml = new QAction( tr( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); 44 showHtml = new QAction( tr( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true );
44 showHtml->addTo( toolbar ); 45 showHtml->addTo( toolbar );
45 showHtml->addTo( mailmenu ); 46 showHtml->addTo( mailmenu );
46 47
47 deleteMail = new QAction(tr("Delete Mail"),SmallIcon("trash"), 0, 0, this); 48 deleteMail = new QAction(tr("Delete Mail"),SmallIcon("trash"), 0, 0, this);
48 deleteMail->addTo(toolbar); 49 deleteMail->addTo(toolbar);
49 deleteMail->addTo(mailmenu); 50 deleteMail->addTo(mailmenu);
50 closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this); 51 closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this);
51 QLabel *spacer = new QLabel(toolbar); 52 QLabel *spacer = new QLabel(toolbar);
52 spacer->setBackgroundMode(QWidget::PaletteButton); 53 spacer->setBackgroundMode(QWidget::PaletteButton);
53 toolbar->setStretchableWidget(spacer); 54 toolbar->setStretchableWidget(spacer);
54 closeMail->addTo(toolbar); 55 closeMail->addTo(toolbar);
55 closeMail->addTo(mailmenu); 56 closeMail->addTo(mailmenu);
56 QVBox *view = new QVBox(this); 57 QVBox *view = new QVBox(this);
57 setCentralWidget(view); 58 setCentralWidget(view);
58 59
59 attachments = new QListView(view); 60 attachments = new QListView(view);
60 attachments->setMinimumHeight(90); 61 attachments->setMinimumHeight(90);
61 attachments->setMaximumHeight(90); 62 attachments->setMaximumHeight(90);
62 attachments->setAllColumnsShowFocus(true); 63 attachments->setAllColumnsShowFocus(true);
63 attachments->addColumn("Mime Type", 60); 64 attachments->addColumn("Mime Type", 60);
64 attachments->addColumn(tr("Description"), 100); 65 attachments->addColumn(tr("Description"), 100);
65 attachments->addColumn(tr("Filename"), 80); 66 attachments->addColumn(tr("Filename"), 80);
66 attachments->addColumn(tr("Size"), 80); 67 attachments->addColumn(tr("Size"), 80);
67 attachments->setSorting(-1); 68 attachments->setSorting(-1);
68 attachments->hide(); 69 attachments->hide();
69 70
70 browser = new QTextBrowser(view); 71 browser = new QTextBrowser(view);
71 72
72 //openDiag = new OpenDiag(view); 73 //openDiag = new OpenDiag(view);
73 //openDiag->hide(); 74 //openDiag->hide();
74 75
75} 76}
76 77
77void ViewMailBase::slotChangeAttachview(bool state) 78void ViewMailBase::slotChangeAttachview(bool state)
78{ 79{
79 if (state) attachments->show(); 80 if (state) attachments->show();
80 else attachments->hide(); 81 else attachments->hide();
81} 82}
82 83
83void ViewMailBase::keyPressEvent ( QKeyEvent * e ) 84void ViewMailBase::keyPressEvent ( QKeyEvent * e )
84{ 85{
85 if( e->key()==Qt::Key_Escape ) { 86 if( e->key()==Qt::Key_Escape ) {
86 close(); 87 close();
87 e->accept(); 88 e->accept();
88 return; 89 return;
89 } 90 }
90 QWidget::keyPressEvent(e); 91 QWidget::keyPressEvent(e);
91} 92}
diff --git a/kmicromail/viewmailbase.h b/kmicromail/viewmailbase.h
index c29d143..1c8948a 100644
--- a/kmicromail/viewmailbase.h
+++ b/kmicromail/viewmailbase.h
@@ -1,38 +1,39 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1#ifndef VIEWMAILBASE_H 2#ifndef VIEWMAILBASE_H
2#define VIEWMAILBASE_H 3#define VIEWMAILBASE_H
3 4
4#include <qmainwindow.h> 5#include <qmainwindow.h>
5 6
6class QAction; 7class QAction;
7class OpenDiag; 8class OpenDiag;
8class QListView; 9class QListView;
9class QToolBar; 10class QToolBar;
10class QTextBrowser; 11class QTextBrowser;
11class QMenuBar; 12class QMenuBar;
12class QPopupMenu; 13class QPopupMenu;
13 14
14class ViewMailBase : public QMainWindow 15class ViewMailBase : public QMainWindow
15{ 16{
16 Q_OBJECT 17 Q_OBJECT
17 18
18public: 19public:
19 ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); 20 ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
20 21
21protected: 22protected:
22 QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml, *closeMail; 23 QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml, *closeMail;
23 QListView *attachments; 24 QListView *attachments;
24 QToolBar *toolbar; 25 QToolBar *toolbar;
25 QTextBrowser *browser; 26 QTextBrowser *browser;
26 OpenDiag *openDiag; 27 OpenDiag *openDiag;
27 QMenuBar *menubar; 28 QMenuBar *menubar;
28 QPopupMenu *mailmenu; 29 QPopupMenu *mailmenu;
29 30
30protected slots: 31protected slots:
31 void slotChangeAttachview(bool state); 32 void slotChangeAttachview(bool state);
32 virtual void keyPressEvent ( QKeyEvent * e ); 33 virtual void keyPressEvent ( QKeyEvent * e );
33 34
34 35
35}; 36};
36 37
37#endif 38#endif
38 39