summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
authorzautrix <zautrix>2004-10-31 16:54:47 (UTC)
committer zautrix <zautrix>2004-10-31 16:54:47 (UTC)
commit3964a158be731f1bb244ca861262df5fa8d04cf3 (patch) (unidiff)
treefa4a8e9af345c144562be480f21df6e3d8d609c7 /kmicromail/opiemail.cpp
parentbed831cc1a38d38a4c5b9329bf37b1c663142c23 (diff)
downloadkdepimpi-3964a158be731f1bb244ca861262df5fa8d04cf3.zip
kdepimpi-3964a158be731f1bb244ca861262df5fa8d04cf3.tar.gz
kdepimpi-3964a158be731f1bb244ca861262df5fa8d04cf3.tar.bz2
changed showmaximized for desktop
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index fe9df87..8d16ae7 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,529 +1,535 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3 3
4#include "koprefsdialog.h" 4#include "koprefsdialog.h"
5#include <kapplication.h> 5#include <kapplication.h>
6#include <libkdepim/externalapphandler.h> 6#include <libkdepim/externalapphandler.h>
7#include <libkdepim/kpimglobalprefs.h> 7#include <libkdepim/kpimglobalprefs.h>
8#ifdef MINIKDE_KDIALOG_H 8#ifdef MINIKDE_KDIALOG_H
9#undef MINIKDE_KDIALOG_H 9#undef MINIKDE_KDIALOG_H
10#endif 10#endif
11#include "settingsdialog.h" 11#include "settingsdialog.h"
12#include "opiemail.h" 12#include "opiemail.h"
13#include "editaccounts.h" 13#include "editaccounts.h"
14#include "composemail.h" 14#include "composemail.h"
15#include "mailistviewitem.h" 15#include "mailistviewitem.h"
16#include "viewmail.h" 16#include "viewmail.h"
17#include "selectstore.h" 17#include "selectstore.h"
18#include "selectsmtp.h" 18#include "selectsmtp.h"
19#include "accountitem.h" 19#include "accountitem.h"
20#include "klocale.h" 20#include "klocale.h"
21 21
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qregexp.h> 25#include <qregexp.h>
26 26
27#ifdef DESKTOP_VERSION 27#ifdef DESKTOP_VERSION
28#include <qapplication.h> 28#include <qapplication.h>
29#else 29#else
30#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
31#endif 31#endif
32#include <libmailwrapper/smtpwrapper.h> 32#include <libmailwrapper/smtpwrapper.h>
33#include <libmailwrapper/mailtypes.h> 33#include <libmailwrapper/mailtypes.h>
34#include <libmailwrapper/abstractmail.h> 34#include <libmailwrapper/abstractmail.h>
35 35
36//using namespace Opie::Core; 36//using namespace Opie::Core;
37 37
38OpieMail::OpieMail( QWidget *parent, const char *name ) 38OpieMail::OpieMail( QWidget *parent, const char *name )
39 : MainWindow( parent, name) //, WStyle_ContextHelp ) 39 : MainWindow( parent, name) //, WStyle_ContextHelp )
40{ 40{
41 settings = new Settings(); 41 settings = new Settings();
42 42
43 setIcon(SmallIcon( "kmicromail" ) ); 43 setIcon(SmallIcon( "kmicromail" ) );
44 folderView->populate( settings->getAccounts() ); 44 folderView->populate( settings->getAccounts() );
45 45
46} 46}
47 47
48OpieMail::~OpieMail() 48OpieMail::~OpieMail()
49{ 49{
50 if (settings) delete settings; 50 if (settings) delete settings;
51} 51}
52 52
53void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 53void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
54{ 54{
55 55
56} 56}
57#include <stdlib.h> 57#include <stdlib.h>
58void OpieMail::message(const QCString &msg, const QByteArray &data) 58void OpieMail::message(const QCString &msg, const QByteArray &data)
59{ 59{
60 // copied from old mail2 60 // copied from old mail2
61 static int ii = 0; 61 static int ii = 0;
62 //qDebug("QCOP CALL ############################# %d ", ii); 62 //qDebug("QCOP CALL ############################# %d ", ii);
63 //QString mess ( msg ); 63 //QString mess ( msg );
64 //qDebug("Message = %s ",mess.latin1()); 64 //qDebug("Message = %s ",mess.latin1());
65 ++ii; 65 ++ii;
66 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 66 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
67 67
68 mPendingEmail = QString::null; 68 mPendingEmail = QString::null;
69 mPendingName = QString::null; 69 mPendingName = QString::null;
70 if (msg == "writeMail(QString,QString)") 70 if (msg == "writeMail(QString,QString)")
71 { 71 {
72 //qDebug("writeMail(QString,QString) "); 72 //qDebug("writeMail(QString,QString) ");
73 QDataStream stream(data,IO_ReadOnly); 73 QDataStream stream(data,IO_ReadOnly);
74 stream >> mPendingName >> mPendingEmail; 74 stream >> mPendingName >> mPendingEmail;
75 // removing the whitespaces at beginning and end is needed! 75 // removing the whitespaces at beginning and end is needed!
76 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 76 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
77 } 77 }
78 else if (msg == "newMail()") 78 else if (msg == "newMail()")
79 { 79 {
80 //qDebug("slotComposeMail() "); 80 //qDebug("slotComposeMail() ");
81 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call 81 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
82 // and a QCOP call does not like a processevents in his execution 82 // and a QCOP call does not like a processevents in his execution
83 // with the Qtimer we call slotComposeMail() after we reached the main event loop 83 // with the Qtimer we call slotComposeMail() after we reached the main event loop
84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
85 // slotComposeMail(); 85 // slotComposeMail();
86 } 86 }
87 else if (msg == "newMail(QString)") 87 else if (msg == "newMail(QString)")
88 { 88 {
89 //qDebug(" newMail(QString)"); 89 //qDebug(" newMail(QString)");
90 QDataStream stream(data,IO_ReadOnly); 90 QDataStream stream(data,IO_ReadOnly);
91 stream >> mPendingName; 91 stream >> mPendingName;
92 // the format is 92 // the format is
93 // NAME <EMAIL>:SUBJECT 93 // NAME <EMAIL>:SUBJECT
94 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 94 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
95 } else { 95 } else {
96 mPendingData = data; 96 mPendingData = data;
97 mPendingMessage = msg; 97 mPendingMessage = msg;
98 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); 98 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
99 } 99 }
100 100
101 //qDebug("END OpieMail::message "); 101 //qDebug("END OpieMail::message ");
102} 102}
103void OpieMail::slotExtAppHandler() 103void OpieMail::slotExtAppHandler()
104{ 104{
105 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 105 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
106} 106}
107void OpieMail::slotwriteMail2(const QString& namemail ) 107void OpieMail::slotwriteMail2(const QString& namemail )
108{ 108{
109 //qDebug("OpieMail::slotwriteMail2 "); 109 //qDebug("OpieMail::slotwriteMail2 ");
110 //qApp->processEvents(); 110 //qApp->processEvents();
111 ComposeMail compose( settings, this, 0, true ); 111 ComposeMail compose( settings, this, 0, true );
112 if ( !namemail.isEmpty() ) { 112 if ( !namemail.isEmpty() ) {
113 QString to = namemail; 113 QString to = namemail;
114 if ( namemail.find( " <") > 1 ) { 114 if ( namemail.find( " <") > 1 ) {
115 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 115 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
116 } else 116 } else
117 if ( namemail.find( "<") > 1 ) { 117 if ( namemail.find( "<") > 1 ) {
118 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 118 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
119 } 119 }
120 int sub = to.find( ">:"); 120 int sub = to.find( ">:");
121 if ( sub > 0 ) { 121 if ( sub > 0 ) {
122 compose.setTo( to.left(sub+1) ); 122 compose.setTo( to.left(sub+1) );
123 compose.setSubject( to.mid(sub+2) ); 123 compose.setSubject( to.mid(sub+2) );
124 } else 124 } else
125 compose.setTo( to ); 125 compose.setTo( to );
126 } 126 }
127 compose.slotAdjustColumns(); 127 compose.slotAdjustColumns();
128#ifndef DESKTOP_VERSION
128 compose.showMaximized(); 129 compose.showMaximized();
130#endif
129 compose.exec(); 131 compose.exec();
130 raise(); 132 raise();
131 //qDebug("retttich "); 133 //qDebug("retttich ");
132} 134}
133void OpieMail::slotwriteMail(const QString&name,const QString&email) 135void OpieMail::slotwriteMail(const QString&name,const QString&email)
134{ 136{
135 // qDebug("OpieMail::slotwriteMail "); 137 // qDebug("OpieMail::slotwriteMail ");
136 ComposeMail compose( settings, this, 0, true ); 138 ComposeMail compose( settings, this, 0, true );
137 if (!email.isEmpty()) 139 if (!email.isEmpty())
138 { 140 {
139 if (!name.isEmpty()) 141 if (!name.isEmpty())
140 { 142 {
141 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 143 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
142 } 144 }
143 else 145 else
144 { 146 {
145 compose.setTo(email); 147 compose.setTo(email);
146 } 148 }
147 } 149 }
148 compose.slotAdjustColumns(); 150 compose.slotAdjustColumns();
151#ifndef DESKTOP_VERSION
149 compose.showMaximized(); 152 compose.showMaximized();
153#endif
150 compose.exec(); 154 compose.exec();
151 raise(); 155 raise();
152} 156}
153 157
154void OpieMail::slotComposeMail() 158void OpieMail::slotComposeMail()
155{ 159{
156 if ( mPendingEmail == QString::null && mPendingName == QString::null) 160 if ( mPendingEmail == QString::null && mPendingName == QString::null)
157 slotwriteMail2( QString () ); 161 slotwriteMail2( QString () );
158 else { 162 else {
159 if ( mPendingEmail == QString::null ) 163 if ( mPendingEmail == QString::null )
160 slotwriteMail2( mPendingName ); 164 slotwriteMail2( mPendingName );
161 else 165 else
162 slotwriteMail( mPendingName, mPendingEmail ); 166 slotwriteMail( mPendingName, mPendingEmail );
163 } 167 }
164 //slotwriteMail(0l,0l); 168 //slotwriteMail(0l,0l);
165} 169}
166 170
167void OpieMail::slotSendQueued() 171void OpieMail::slotSendQueued()
168{ 172{
169 SMTPaccount *smtp = 0; 173 SMTPaccount *smtp = 0;
170 174
171 QList<Account> list = settings->getAccounts(); 175 QList<Account> list = settings->getAccounts();
172 QList<SMTPaccount> smtpList; 176 QList<SMTPaccount> smtpList;
173 smtpList.setAutoDelete(false); 177 smtpList.setAutoDelete(false);
174 Account *it; 178 Account *it;
175 for ( it = list.first(); it; it = list.next() ) 179 for ( it = list.first(); it; it = list.next() )
176 { 180 {
177 if ( it->getType() == MAILLIB::A_SMTP ) 181 if ( it->getType() == MAILLIB::A_SMTP )
178 { 182 {
179 smtp = static_cast<SMTPaccount *>(it); 183 smtp = static_cast<SMTPaccount *>(it);
180 smtpList.append(smtp); 184 smtpList.append(smtp);
181 } 185 }
182 } 186 }
183 if (smtpList.count()==0) 187 if (smtpList.count()==0)
184 { 188 {
185 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); 189 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n"));
186 return; 190 return;
187 } 191 }
188 if (smtpList.count()==1) 192 if (smtpList.count()==1)
189 { 193 {
190 smtp = smtpList.at(0); 194 smtp = smtpList.at(0);
191 } 195 }
192 else 196 else
193 { 197 {
194 smtp = 0; 198 smtp = 0;
195 selectsmtp selsmtp; 199 selectsmtp selsmtp;
196 selsmtp.setSelectionlist(&smtpList); 200 selsmtp.setSelectionlist(&smtpList);
201#ifndef DESKTOP_VERSION
197 selsmtp.showMaximized(); 202 selsmtp.showMaximized();
203#endif
198 if ( selsmtp.exec() == QDialog::Accepted ) 204 if ( selsmtp.exec() == QDialog::Accepted )
199 { 205 {
200 smtp = selsmtp.selected_smtp(); 206 smtp = selsmtp.selected_smtp();
201 } 207 }
202 } 208 }
203 if (smtp) 209 if (smtp)
204 { 210 {
205 SMTPwrapper * wrap = new SMTPwrapper(smtp); 211 SMTPwrapper * wrap = new SMTPwrapper(smtp);
206 if ( wrap->flushOutbox() ) 212 if ( wrap->flushOutbox() )
207 { 213 {
208 QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); 214 QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed"));
209 } 215 }
210 delete wrap; 216 delete wrap;
211 } 217 }
212} 218}
213 219
214void OpieMail::slotSearchMails() 220void OpieMail::slotSearchMails()
215{ 221{
216 qDebug("OpieMail::slotSearchMails():not implemented "); 222 qDebug("OpieMail::slotSearchMails():not implemented ");
217} 223}
218 224
219void OpieMail::slotEditSettings() 225void OpieMail::slotEditSettings()
220{ 226{
221 227
222 KOPrefsDialog settingsDialog( this, "koprefs", true ); 228 KOPrefsDialog settingsDialog( this, "koprefs", true );
223#ifndef DESKTOP_VERSION 229#ifndef DESKTOP_VERSION
224 settingsDialog.showMaximized(); 230 settingsDialog.showMaximized();
225#endif 231#endif
226 settingsDialog.exec(); 232 settingsDialog.exec();
227 233
228 // KApplication::execDialog(settingsDialog); 234 // KApplication::execDialog(settingsDialog);
229} 235}
230 236
231void OpieMail::slotEditAccounts() 237void OpieMail::slotEditAccounts()
232{ 238{
233 EditAccounts eaDialog( settings, this, 0, true ); 239 EditAccounts eaDialog( settings, this, 0, true );
234 eaDialog.slotAdjustColumns(); 240 eaDialog.slotAdjustColumns();
235#ifndef DESKTOP_VERSION 241#ifndef DESKTOP_VERSION
236 eaDialog.showMaximized(); 242 eaDialog.showMaximized();
237#endif 243#endif
238 eaDialog.exec(); 244 eaDialog.exec();
239 if ( settings ) delete settings; 245 if ( settings ) delete settings;
240 settings = new Settings(); 246 settings = new Settings();
241 247
242 folderView->populate( settings->getAccounts() ); 248 folderView->populate( settings->getAccounts() );
243} 249}
244void OpieMail::replyMail() 250void OpieMail::replyMail()
245{ 251{
246 252
247 QListViewItem*item = mailView->currentItem(); 253 QListViewItem*item = mailView->currentItem();
248 if (!item) return; 254 if (!item) return;
249 RecMailP mail = ((MailListViewItem*)item)->data(); 255 RecMailP mail = ((MailListViewItem*)item)->data();
250 RecBodyP body = folderView->fetchBody(mail); 256 RecBodyP body = folderView->fetchBody(mail);
251 257
252 QString rtext; 258 QString rtext;
253 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 259 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
254 .arg( QString::fromUtf8( mail->getFrom().latin1())) 260 .arg( QString::fromUtf8( mail->getFrom().latin1()))
255 .arg( QString::fromUtf8( mail->getDate().latin1() )); 261 .arg( QString::fromUtf8( mail->getDate().latin1() ));
256 262
257 QString text = QString::fromUtf8( body->Bodytext().latin1() ); 263 QString text = QString::fromUtf8( body->Bodytext().latin1() );
258 QStringList lines = QStringList::split(QRegExp("\\n"), text); 264 QStringList lines = QStringList::split(QRegExp("\\n"), text);
259 QStringList::Iterator it; 265 QStringList::Iterator it;
260 for (it = lines.begin(); it != lines.end(); it++) 266 for (it = lines.begin(); it != lines.end(); it++)
261 { 267 {
262 rtext += "> " + *it + "\n"; 268 rtext += "> " + *it + "\n";
263 } 269 }
264 rtext += "\n"; 270 rtext += "\n";
265 271
266 QString prefix; 272 QString prefix;
267 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 273 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
268 else prefix = "Re: "; // no i18n on purpose 274 else prefix = "Re: "; // no i18n on purpose
269 275
270 Settings *settings = new Settings(); 276 Settings *settings = new Settings();
271 ComposeMail composer( settings ,this, 0, true); 277 ComposeMail composer( settings ,this, 0, true);
272 if (mail->Replyto().isEmpty()) { 278 if (mail->Replyto().isEmpty()) {
273 composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); 279 composer.setTo( QString::fromUtf8( mail->getFrom().latin1()));
274 } else { 280 } else {
275 composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); 281 composer.setTo( QString::fromUtf8(mail->Replyto().latin1()));
276 } 282 }
277 composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); 283 composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) );
278 composer.setMessage( rtext ); 284 composer.setMessage( rtext );
279 composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); 285 composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1()));
280 286
281 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 287 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
282 { 288 {
283 mail->Wrapper()->answeredMail(mail); 289 mail->Wrapper()->answeredMail(mail);
284 } 290 }
285 delete settings; 291 delete settings;
286 292
287} 293}
288void OpieMail::displayMail() 294void OpieMail::displayMail()
289{ 295{
290 QListViewItem*item = mailView->currentItem(); 296 QListViewItem*item = mailView->currentItem();
291 if (!item) return; 297 if (!item) return;
292 RecMailP mail = ((MailListViewItem*)item)->data(); 298 RecMailP mail = ((MailListViewItem*)item)->data();
293 RecBodyP body = folderView->fetchBody(mail); 299 RecBodyP body = folderView->fetchBody(mail);
294 ViewMail readMail( this,"", Qt::WType_Modal ); 300 ViewMail readMail( this,"", Qt::WType_Modal );
295 readMail.setBody( body ); 301 readMail.setBody( body );
296 readMail.setMail( mail ); 302 readMail.setMail( mail );
297#ifndef DESKTOP_VERSION 303#ifndef DESKTOP_VERSION
298 readMail.showMaximized(); 304 readMail.showMaximized();
299#else 305#else
300 readMail.resize( 640, 480); 306 readMail.resize( 640, 480);
301#endif 307#endif
302 readMail.exec(); 308 readMail.exec();
303 309
304 if ( readMail.deleted ) 310 if ( readMail.deleted )
305 { 311 {
306 folderView->refreshCurrent(); 312 folderView->refreshCurrent();
307 } 313 }
308 else 314 else
309 { 315 {
310 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 316 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
311 } 317 }
312} 318}
313void OpieMail::slotGetAllMail() 319void OpieMail::slotGetAllMail()
314{ 320{
315 QListViewItem * item = folderView->firstChild(); 321 QListViewItem * item = folderView->firstChild();
316 while ( item ){ 322 while ( item ){
317 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 323 ((AccountViewItem *)item)->contextMenuSelected( 101 );
318 item = item->nextSibling (); 324 item = item->nextSibling ();
319 } 325 }
320} 326}
321void OpieMail::slotGetMail() 327void OpieMail::slotGetMail()
322{ 328{
323 QListViewItem * item = folderView->currentItem(); 329 QListViewItem * item = folderView->currentItem();
324 if ( ! item ) return; 330 if ( ! item ) return;
325 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 331 ((AccountViewItem *)item)->contextMenuSelected( 101 );
326} 332}
327void OpieMail::slotDeleteMail() 333void OpieMail::slotDeleteMail()
328{ 334{
329 if (!mailView->currentItem()) return; 335 if (!mailView->currentItem()) return;
330 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 336 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
331 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 337 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
332 { 338 {
333 mail->Wrapper()->deleteMail( mail ); 339 mail->Wrapper()->deleteMail( mail );
334 folderView->refreshCurrent(); 340 folderView->refreshCurrent();
335 } 341 }
336} 342}
337void OpieMail::slotDeleteAllMail() 343void OpieMail::slotDeleteAllMail()
338{ 344{
339 345
340 QValueList<RecMailP> t; 346 QValueList<RecMailP> t;
341 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 347 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
342 { 348 {
343 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 349 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
344 while ( item ) { 350 while ( item ) {
345 if ( item->isSelected() ) { 351 if ( item->isSelected() ) {
346 t.append( item->data() ); 352 t.append( item->data() );
347 } 353 }
348 item = (MailListViewItem*)item->nextSibling(); 354 item = (MailListViewItem*)item->nextSibling();
349 } 355 }
350 } 356 }
351 else 357 else
352 return; 358 return;
353 if ( t.count() == 0 ) 359 if ( t.count() == 0 )
354 return; 360 return;
355 RecMailP mail = t.first(); 361 RecMailP mail = t.first();
356 mail->Wrapper()->deleteMailList(t); 362 mail->Wrapper()->deleteMailList(t);
357 folderView->refreshCurrent(); 363 folderView->refreshCurrent();
358 364
359 365
360} 366}
361void OpieMail::clearSelection() 367void OpieMail::clearSelection()
362{ 368{
363 mailView->clearSelection(); 369 mailView->clearSelection();
364 370
365} 371}
366 372
367void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 373void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
368{ 374{
369 if (!mailView->currentItem()) return; 375 if (!mailView->currentItem()) return;
370 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 376 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
371 /* just the RIGHT button - or hold on pda */ 377 /* just the RIGHT button - or hold on pda */
372 if (button!=2) {return;} 378 if (button!=2) {return;}
373 if (!item) return; 379 if (!item) return;
374 QPopupMenu *m = new QPopupMenu(0); 380 QPopupMenu *m = new QPopupMenu(0);
375 if (m) 381 if (m)
376 { 382 {
377 if (mailtype==MAILLIB::A_NNTP) { 383 if (mailtype==MAILLIB::A_NNTP) {
378 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); 384 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail()));
379 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); 385 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail()));
380 m->insertSeparator(); 386 m->insertSeparator();
381 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); 387 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail()));
382 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 388 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
383 } else { 389 } else {
384 if (folderView->currentisDraft()) { 390 if (folderView->currentisDraft()) {
385 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); 391 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail()));
386 } 392 }
387 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); 393 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail()));
388 m->insertSeparator(); 394 m->insertSeparator();
389 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); 395 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail()));
390 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 396 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
391 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); 397 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail()));
392 m->insertSeparator(); 398 m->insertSeparator();
393 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 399 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
394 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 400 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
395 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 401 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
396 } 402 }
397 m->setFocus(); 403 m->setFocus();
398 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 404 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
399 delete m; 405 delete m;
400 } 406 }
401} 407}
402 408
403void OpieMail::slotShowFolders( bool show ) 409void OpieMail::slotShowFolders( bool show )
404{ 410{
405 if ( show && folderView->isHidden() ) 411 if ( show && folderView->isHidden() )
406 { 412 {
407 folderView->show(); 413 folderView->show();
408 } 414 }
409 else if ( !show && !folderView->isHidden() ) 415 else if ( !show && !folderView->isHidden() )
410 { 416 {
411 folderView->hide(); 417 folderView->hide();
412 } 418 }
413} 419}
414 420
415void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 421void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
416{ 422{
417 MailListViewItem*item = 0; 423 MailListViewItem*item = 0;
418 mailView->clear(); 424 mailView->clear();
419 425
420 QValueList<RecMailP>::ConstIterator it; 426 QValueList<RecMailP>::ConstIterator it;
421 for (it = list.begin(); it != list.end();++it) 427 for (it = list.begin(); it != list.end();++it)
422 { 428 {
423 item = new MailListViewItem(mailView,item); 429 item = new MailListViewItem(mailView,item);
424 item->storeData((*it)); 430 item->storeData((*it));
425 item->showEntry(); 431 item->showEntry();
426 } 432 }
427} 433}
428 434
429void OpieMail::mailLeftClicked( QListViewItem *item ) 435void OpieMail::mailLeftClicked( QListViewItem *item )
430{ 436{
431 mailView->clearSelection(); 437 mailView->clearSelection();
432 /* just LEFT button - or tap with stylus on pda */ 438 /* just LEFT button - or tap with stylus on pda */
433 //if (button!=1) return; 439 //if (button!=1) return;
434 if (!item) return; 440 if (!item) return;
435 if (folderView->currentisDraft()) { 441 if (folderView->currentisDraft()) {
436 reEditMail(); 442 reEditMail();
437 } else { 443 } else {
438 displayMail(); 444 displayMail();
439 } 445 }
440} 446}
441 447
442void OpieMail::slotMoveCopyMail() 448void OpieMail::slotMoveCopyMail()
443{ 449{
444 if (!mailView->currentItem()) return; 450 if (!mailView->currentItem()) return;
445 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 451 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
446 AbstractMail*targetMail = 0; 452 AbstractMail*targetMail = 0;
447 QString targetFolder = ""; 453 QString targetFolder = "";
448 Selectstore sels; 454 Selectstore sels;
449 folderView->setupFolderselect(&sels); 455 folderView->setupFolderselect(&sels);
450 if (!sels.exec()) return; 456 if (!sels.exec()) return;
451 targetMail = sels.currentMail(); 457 targetMail = sels.currentMail();
452 targetFolder = sels.currentFolder(); 458 targetFolder = sels.currentFolder();
453 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 459 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
454 targetFolder.isEmpty()) 460 targetFolder.isEmpty())
455 { 461 {
456 return; 462 return;
457 } 463 }
458 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 464 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
459 { 465 {
460 QMessageBox::critical(0,i18n("Error creating new Folder"), 466 QMessageBox::critical(0,i18n("Error creating new Folder"),
461 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 467 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
462 return; 468 return;
463 } 469 }
464 sels.hide(); 470 sels.hide();
465 qApp->processEvents(); 471 qApp->processEvents();
466 // qDebug("hiding sels "); 472 // qDebug("hiding sels ");
467 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 473 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
468 folderView->refreshCurrent(); 474 folderView->refreshCurrent();
469} 475}
470 476
471void OpieMail::slotMoveCopyAllMail() 477void OpieMail::slotMoveCopyAllMail()
472{ 478{
473 479
474 if (!mailView->currentItem()) return; 480 if (!mailView->currentItem()) return;
475 QValueList<RecMailP> t; 481 QValueList<RecMailP> t;
476 // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 482 // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
477 { 483 {
478 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 484 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
479 while ( item ) { 485 while ( item ) {
480 if ( item->isSelected() ) { 486 if ( item->isSelected() ) {
481 t.append( item->data() ); 487 t.append( item->data() );
482 } 488 }
483 item = (MailListViewItem*)item->nextSibling(); 489 item = (MailListViewItem*)item->nextSibling();
484 } 490 }
485 } 491 }
486 // else 492 // else
487 // return; 493 // return;
488 if ( t.count() == 0 ) 494 if ( t.count() == 0 )
489 return; 495 return;
490 RecMailP mail = t.first(); 496 RecMailP mail = t.first();
491 AbstractMail*targetMail = 0; 497 AbstractMail*targetMail = 0;
492 QString targetFolder = ""; 498 QString targetFolder = "";
493 Selectstore sels; 499 Selectstore sels;
494 folderView->setupFolderselect(&sels); 500 folderView->setupFolderselect(&sels);
495 if (!sels.exec()) return; 501 if (!sels.exec()) return;
496 targetMail = sels.currentMail(); 502 targetMail = sels.currentMail();
497 targetFolder = sels.currentFolder(); 503 targetFolder = sels.currentFolder();
498 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 504 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
499 targetFolder.isEmpty()) 505 targetFolder.isEmpty())
500 { 506 {
501 return; 507 return;
502 } 508 }
503 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 509 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
504 { 510 {
505 QMessageBox::critical(0,i18n("Error creating new Folder"), 511 QMessageBox::critical(0,i18n("Error creating new Folder"),
506 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 512 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
507 return; 513 return;
508 } 514 }
509 sels.hide(); 515 sels.hide();
510 qApp->processEvents(); 516 qApp->processEvents();
511 //qDebug("hiding sels "); 517 //qDebug("hiding sels ");
512 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 518 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
513 folderView->refreshCurrent(); 519 folderView->refreshCurrent();
514} 520}
515 521
516void OpieMail::reEditMail() 522void OpieMail::reEditMail()
517{ 523{
518 if (!mailView->currentItem()) return; 524 if (!mailView->currentItem()) return;
519 525
520 ComposeMail compose( settings, this, 0, true ); 526 ComposeMail compose( settings, this, 0, true );
521 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 527 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
522 compose.slotAdjustColumns(); 528 compose.slotAdjustColumns();
523#ifndef DESKTOP_VERSION 529#ifndef DESKTOP_VERSION
524 compose.showMaximized(); 530 compose.showMaximized();
525#else 531#else
526 compose.resize(640,480); 532 compose.resize(640,480);
527#endif 533#endif
528 compose.exec(); 534 compose.exec();
529} 535}