summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
authorzautrix <zautrix>2004-07-04 12:40:46 (UTC)
committer zautrix <zautrix>2004-07-04 12:40:46 (UTC)
commitdeb87bff56cd9cbb41e352c2ccfa97be142d6e48 (patch) (unidiff)
treed711d6085e4143e1731da440732e823e69c092a3 /kmicromail/opiemail.cpp
parent4a947dbc08cc7640dda4f8a89ddb3c80ecc5f9ea (diff)
downloadkdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.zip
kdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.tar.gz
kdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.tar.bz2
Make sorting in KM working
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index b1992ec..bdbd93a 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -23,257 +23,257 @@
23using namespace Opie::Core; 23using namespace Opie::Core;
24 24
25OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 25OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
26 : MainWindow( parent, name, WStyle_ContextHelp ) 26 : MainWindow( parent, name, WStyle_ContextHelp )
27{ 27{
28 settings = new Settings(); 28 settings = new Settings();
29 29
30 folderView->populate( settings->getAccounts() ); 30 folderView->populate( settings->getAccounts() );
31 31
32} 32}
33 33
34OpieMail::~OpieMail() 34OpieMail::~OpieMail()
35{ 35{
36 if (settings) delete settings; 36 if (settings) delete settings;
37} 37}
38 38
39void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 39void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
40{ 40{
41 41
42} 42}
43#include <stdlib.h> 43#include <stdlib.h>
44void OpieMail::message(const QCString &msg, const QByteArray &data) 44void OpieMail::message(const QCString &msg, const QByteArray &data)
45{ 45{
46 // copied from old mail2 46 // copied from old mail2
47 static int ii = 0; 47 static int ii = 0;
48 48
49 // block second call 49 // block second call
50 if ( ii < 2 ) { 50 if ( ii < 2 ) {
51 ++ii; 51 ++ii;
52 if ( ii > 1 ) { 52 if ( ii > 1 ) {
53 qDebug("qcop call blocked "); 53 qDebug("qcop call blocked ");
54 return; 54 return;
55 } 55 }
56 } 56 }
57 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 57 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
58 if (msg == "writeMail(QString,QString)") 58 if (msg == "writeMail(QString,QString)")
59 { 59 {
60 QDataStream stream(data,IO_ReadOnly); 60 QDataStream stream(data,IO_ReadOnly);
61 QString name, email; 61 QString name, email;
62 stream >> name >> email; 62 stream >> name >> email;
63 // removing the whitespaces at beginning and end is needed! 63 // removing the whitespaces at beginning and end is needed!
64 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 64 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
65 } 65 }
66 else if (msg == "newMail()") 66 else if (msg == "newMail()")
67 { 67 {
68 slotComposeMail(); 68 slotComposeMail();
69 } 69 }
70 else if (msg == "newMail(QString)") 70 else if (msg == "newMail(QString)")
71 { 71 {
72 QDataStream stream(data,IO_ReadOnly); 72 QDataStream stream(data,IO_ReadOnly);
73 QString nameemail; 73 QString nameemail;
74 stream >> nameemail; 74 stream >> nameemail;
75 // the format is 75 // the format is
76 // NAME <EMAIL>:SUBJECT 76 // NAME <EMAIL>:SUBJECT
77 //qDebug("message %s ", nameemail.latin1()); 77 //qDebug("message %s ", nameemail.latin1());
78 78
79 slotwriteMail2( nameemail ); 79 slotwriteMail2( nameemail );
80 } 80 }
81} 81}
82void OpieMail::slotwriteMail2(const QString& namemail ) 82void OpieMail::slotwriteMail2(const QString& namemail )
83{ 83{
84 // qDebug("OpieMail::slotwriteMail2 "); 84 // qDebug("OpieMail::slotwriteMail2 ");
85 qApp->processEvents(); 85 qApp->processEvents();
86 ComposeMail compose( settings, this, 0, true ); 86 ComposeMail compose( settings, this, 0, true );
87 if ( !namemail.isEmpty() ) { 87 if ( !namemail.isEmpty() ) {
88 QString to = namemail; 88 QString to = namemail;
89 if ( namemail.find( " <") > 1 ) { 89 if ( namemail.find( " <") > 1 ) {
90 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 90 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
91 } else 91 } else
92 if ( namemail.find( "<") > 1 ) { 92 if ( namemail.find( "<") > 1 ) {
93 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 93 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
94 } 94 }
95 int sub = to.find( ">:"); 95 int sub = to.find( ">:");
96 if ( sub > 0 ) { 96 if ( sub > 0 ) {
97 compose.setTo( to.left(sub+1) ); 97 compose.setTo( to.left(sub+1) );
98 compose.setSubject( to.mid(sub+2) ); 98 compose.setSubject( to.mid(sub+2) );
99 } else 99 } else
100 compose.setTo( to ); 100 compose.setTo( to );
101 } 101 }
102 compose.slotAdjustColumns(); 102 compose.slotAdjustColumns();
103 compose.showMaximized(); 103 compose.showMaximized();
104 compose.exec(); 104 compose.exec();
105 //qDebug("retttich "); 105 //qDebug("retttich ");
106} 106}
107void OpieMail::slotwriteMail(const QString&name,const QString&email) 107void OpieMail::slotwriteMail(const QString&name,const QString&email)
108{ 108{
109 // qDebug("OpieMail::slotwriteMail "); 109 // qDebug("OpieMail::slotwriteMail ");
110 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 110 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
111 if (!email.isEmpty()) 111 if (!email.isEmpty())
112 { 112 {
113 if (!name.isEmpty()) 113 if (!name.isEmpty())
114 { 114 {
115 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 115 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
116 } 116 }
117 else 117 else
118 { 118 {
119 compose.setTo(email); 119 compose.setTo(email);
120 } 120 }
121 } 121 }
122 compose.slotAdjustColumns(); 122 compose.slotAdjustColumns();
123 compose.showMaximized(); 123 compose.showMaximized();
124 compose.exec(); 124 compose.exec();
125} 125}
126 126
127void OpieMail::slotComposeMail() 127void OpieMail::slotComposeMail()
128{ 128{
129 slotwriteMail2( QString () ); 129 slotwriteMail2( QString () );
130 //slotwriteMail(0l,0l); 130 //slotwriteMail(0l,0l);
131} 131}
132 132
133void OpieMail::slotSendQueued() 133void OpieMail::slotSendQueued()
134{ 134{
135 SMTPaccount *smtp = 0; 135 SMTPaccount *smtp = 0;
136 136
137 QList<Account> list = settings->getAccounts(); 137 QList<Account> list = settings->getAccounts();
138 QList<SMTPaccount> smtpList; 138 QList<SMTPaccount> smtpList;
139 smtpList.setAutoDelete(false); 139 smtpList.setAutoDelete(false);
140 Account *it; 140 Account *it;
141 for ( it = list.first(); it; it = list.next() ) 141 for ( it = list.first(); it; it = list.next() )
142 { 142 {
143 if ( it->getType() == MAILLIB::A_SMTP ) 143 if ( it->getType() == MAILLIB::A_SMTP )
144 { 144 {
145 smtp = static_cast<SMTPaccount *>(it); 145 smtp = static_cast<SMTPaccount *>(it);
146 smtpList.append(smtp); 146 smtpList.append(smtp);
147 } 147 }
148 } 148 }
149 if (smtpList.count()==0) 149 if (smtpList.count()==0)
150 { 150 {
151 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 151 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n"));
152 return; 152 return;
153 } 153 }
154 if (smtpList.count()==1) 154 if (smtpList.count()==1)
155 { 155 {
156 smtp = smtpList.at(0); 156 smtp = smtpList.at(0);
157 } 157 }
158 else 158 else
159 { 159 {
160 smtp = 0; 160 smtp = 0;
161 selectsmtp selsmtp; 161 selectsmtp selsmtp;
162 selsmtp.setSelectionlist(&smtpList); 162 selsmtp.setSelectionlist(&smtpList);
163 selsmtp.showMaximized(); 163 selsmtp.showMaximized();
164 if ( selsmtp.exec() == QDialog::Accepted ) 164 if ( selsmtp.exec() == QDialog::Accepted )
165 { 165 {
166 smtp = selsmtp.selected_smtp(); 166 smtp = selsmtp.selected_smtp();
167 } 167 }
168 } 168 }
169 if (smtp) 169 if (smtp)
170 { 170 {
171 SMTPwrapper * wrap = new SMTPwrapper(smtp); 171 SMTPwrapper * wrap = new SMTPwrapper(smtp);
172 if ( wrap->flushOutbox() ) 172 if ( wrap->flushOutbox() )
173 { 173 {
174 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 174 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
175 } 175 }
176 delete wrap; 176 delete wrap;
177 } 177 }
178} 178}
179 179
180void OpieMail::slotSearchMails() 180void OpieMail::slotSearchMails()
181{ 181{
182 qDebug("OpieMail::slotSearchMails():not implemented "); 182 qDebug("OpieMail::slotSearchMails():not implemented ");
183} 183}
184 184
185void OpieMail::slotEditSettings() 185void OpieMail::slotEditSettings()
186{ 186{
187 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 187 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
188 settingsDialog.showMaximized(); 188 settingsDialog.showMaximized();
189 settingsDialog.exec(); 189 settingsDialog.exec();
190} 190}
191 191
192void OpieMail::slotEditAccounts() 192void OpieMail::slotEditAccounts()
193{ 193{
194 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 194 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
195 eaDialog.slotAdjustColumns(); 195 eaDialog.slotAdjustColumns();
196 eaDialog.showMaximized(); 196 eaDialog.showMaximized();
197 eaDialog.exec(); 197 eaDialog.exec();
198 if ( settings ) delete settings; 198 if ( settings ) delete settings;
199 settings = new Settings(); 199 settings = new Settings();
200 200
201 folderView->populate( settings->getAccounts() ); 201 folderView->populate( settings->getAccounts() );
202} 202}
203 203
204void OpieMail::displayMail() 204void OpieMail::displayMail()
205{ 205{
206 QListViewItem*item = mailView->currentItem(); 206 QListViewItem*item = mailView->currentItem();
207 if (!item) return; 207 if (!item) return;
208 RecMailP mail = ((MailListViewItem*)item)->data(); 208 RecMailP mail = ((MailListViewItem*)item)->data();
209 RecBodyP body = folderView->fetchBody(mail); 209 RecBodyP body = folderView->fetchBody(mail);
210 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 210 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
211 readMail.setBody( body ); 211 readMail.setBody( body );
212 readMail.setMail( mail ); 212 readMail.setMail( mail );
213 readMail.showMaximized(); 213 readMail.showMaximized();
214 readMail.exec(); 214 readMail.exec();
215 215
216 if ( readMail.deleted ) 216 if ( readMail.deleted )
217 { 217 {
218 folderView->refreshCurrent(); 218 folderView->refreshCurrent();
219 } 219 }
220 else 220 else
221 { 221 {
222 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 222 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
223 } 223 }
224} 224}
225 225
226void OpieMail::slotDeleteMail() 226void OpieMail::slotDeleteMail()
227{ 227{
228 if (!mailView->currentItem()) return; 228 if (!mailView->currentItem()) return;
229 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 229 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 ) 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 { 231 {
232 mail->Wrapper()->deleteMail( mail ); 232 mail->Wrapper()->deleteMail( mail );
233 folderView->refreshCurrent(); 233 folderView->refreshCurrent();
234 } 234 }
235} 235}
236void OpieMail::slotDeleteAllMail() 236void OpieMail::slotDeleteAllMail()
237{ 237{
238 if (!mailView->currentItem()) return; 238 if (!mailView->currentItem()) return;
239 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 239 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 ) 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 { 241 {
242 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 242 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
243 while ( item ) { 243 while ( item ) {
244 if ( item->isSelected() ) { 244 if ( item->isSelected() ) {
245 RecMailP mail = item->data(); 245 RecMailP mail = item->data();
246 mail->Wrapper()->deleteMail( mail ); 246 mail->Wrapper()->deleteMail( mail );
247 } 247 }
248 item = (MailListViewItem*)item->nextSibling(); 248 item = (MailListViewItem*)item->nextSibling();
249 } 249 }
250 folderView->refreshCurrent(); 250 folderView->refreshCurrent();
251 } 251 }
252} 252}
253void OpieMail::clearSelection() 253void OpieMail::clearSelection()
254{ 254{
255 mailView->clearSelection(); 255 mailView->clearSelection();
256 256
257} 257}
258 258
259void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 259void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
260{ 260{
261 if (!mailView->currentItem()) return; 261 if (!mailView->currentItem()) return;
262 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 262 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
263 /* just the RIGHT button - or hold on pda */ 263 /* just the RIGHT button - or hold on pda */
264 if (button!=2) {return;} 264 if (button!=2) {return;}
265 if (!item) return; 265 if (!item) return;
266 QPopupMenu *m = new QPopupMenu(0); 266 QPopupMenu *m = new QPopupMenu(0);
267 if (m) 267 if (m)
268 { 268 {
269 if (mailtype==MAILLIB::A_NNTP) { 269 if (mailtype==MAILLIB::A_NNTP) {
270 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 270 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
271// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 271// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
272 } else { 272 } else {
273 if (folderView->currentisDraft()) { 273 if (folderView->currentisDraft()) {
274 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 274 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
275 } 275 }
276 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 276 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
277 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 277 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
278 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 278 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
279 m->insertSeparator(); 279 m->insertSeparator();