-rw-r--r-- | noncore/net/mail/accountview.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 30 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 1 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.cpp | 65 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 151 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 119 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.h | 8 |
13 files changed, 263 insertions, 140 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index b7de7b9..9f4f358 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -871,12 +871,20 @@ QPopupMenu * MBOXfolderItem::getContextMenu() | |||
871 | QPopupMenu *m = new QPopupMenu(0); | 871 | QPopupMenu *m = new QPopupMenu(0); |
872 | if (m) { | 872 | if (m) { |
873 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 873 | m->insertItem(QObject::tr("Delete all mails",contextName),0); |
874 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 874 | m->insertItem(QObject::tr("Delete folder",contextName),1); |
875 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | ||
875 | } | 876 | } |
876 | return m; | 877 | return m; |
877 | } | 878 | } |
878 | 879 | ||
880 | void MBOXfolderItem::downloadMails() | ||
881 | { | ||
882 | AccountView*bl = mbox->accountView(); | ||
883 | if (!bl) return; | ||
884 | bl->downloadMails(folder,mbox->getWrapper()); | ||
885 | } | ||
886 | |||
879 | void MBOXfolderItem::contextMenuSelected(int which) | 887 | void MBOXfolderItem::contextMenuSelected(int which) |
880 | { | 888 | { |
881 | switch(which) { | 889 | switch(which) { |
882 | case 0: | 890 | case 0: |
@@ -884,8 +892,11 @@ void MBOXfolderItem::contextMenuSelected(int which) | |||
884 | break; | 892 | break; |
885 | case 1: | 893 | case 1: |
886 | deleteFolder(); | 894 | deleteFolder(); |
887 | break; | 895 | break; |
896 | case 2: | ||
897 | downloadMails(); | ||
898 | break; | ||
888 | default: | 899 | default: |
889 | break; | 900 | break; |
890 | } | 901 | } |
891 | } | 902 | } |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index df916c1..d9b5558 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -152,8 +152,9 @@ public: | |||
152 | virtual void contextMenuSelected(int); | 152 | virtual void contextMenuSelected(int); |
153 | virtual Folder*getFolder(); | 153 | virtual Folder*getFolder(); |
154 | 154 | ||
155 | protected: | 155 | protected: |
156 | void downloadMails(); | ||
156 | virtual void deleteFolder(); | 157 | virtual void deleteFolder(); |
157 | Folder *folder; | 158 | Folder *folder; |
158 | MBOXviewItem *mbox; | 159 | MBOXviewItem *mbox; |
159 | }; | 160 | }; |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 4b4c728..0280803 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -122,4 +122,17 @@ void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abs | |||
122 | if (moveit) { | 122 | if (moveit) { |
123 | deleteAllMail(fromFolder); | 123 | deleteAllMail(fromFolder); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | |||
127 | void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
128 | { | ||
129 | encodedString*st = 0; | ||
130 | st = fetchRawBody(mail); | ||
131 | if (st) { | ||
132 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | ||
133 | delete st; | ||
134 | } | ||
135 | if (moveit) { | ||
136 | deleteMail(mail); | ||
137 | } | ||
138 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 8debaae..f93bab4 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -35,8 +35,9 @@ public: | |||
35 | virtual int deleteMbox(const Folder*)=0; | 35 | virtual int deleteMbox(const Folder*)=0; |
36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
37 | 37 | ||
38 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 38 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
39 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
39 | 40 | ||
40 | virtual void cleanMimeCache(){}; | 41 | virtual void cleanMimeCache(){}; |
41 | /* mail box methods */ | 42 | /* mail box methods */ |
42 | /* parameter is the box to create. | 43 | /* parameter is the box to create. |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 98634a3..4b633ea 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1055,4 +1055,34 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst | |||
1055 | if (moveit) { | 1055 | if (moveit) { |
1056 | deleteAllMail(fromFolder); | 1056 | deleteAllMail(fromFolder); |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | |||
1060 | void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
1061 | { | ||
1062 | if (targetWrapper != this) { | ||
1063 | qDebug("Using generic"); | ||
1064 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | ||
1065 | return; | ||
1066 | } | ||
1067 | mailimap_set *set = 0; | ||
1068 | login(); | ||
1069 | if (!m_imap) { | ||
1070 | return; | ||
1071 | } | ||
1072 | int err = selectMbox(mail.getMbox()); | ||
1073 | if ( err != MAILIMAP_NO_ERROR ) { | ||
1074 | return; | ||
1075 | } | ||
1076 | set = mailimap_set_new_single(mail.getNumber()); | ||
1077 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | ||
1078 | mailimap_set_free( set ); | ||
1079 | if ( err != MAILIMAP_NO_ERROR ) { | ||
1080 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | ||
1081 | Global::statusMessage(error_msg); | ||
1082 | qDebug(error_msg); | ||
1083 | return; | ||
1084 | } | ||
1085 | if (moveit) { | ||
1086 | deleteMail(mail); | ||
1087 | } | ||
1088 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 99986c2..c10f86a 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -31,8 +31,9 @@ public: | |||
31 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMail&mail); |
32 | virtual int deleteAllMail(const Folder*folder); | 32 | virtual int deleteAllMail(const Folder*folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 34 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
35 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
35 | 36 | ||
36 | virtual RecBody fetchBody(const RecMail&mail); | 37 | virtual RecBody fetchBody(const RecMail&mail); |
37 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 38 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
38 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 39 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 1abd2e8..90e1e46 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro | |||
@@ -22,8 +22,9 @@ SOURCES = main.cpp \ | |||
22 | addresspicker.cpp \ | 22 | addresspicker.cpp \ |
23 | editaccounts.cpp \ | 23 | editaccounts.cpp \ |
24 | viewmail.cpp \ | 24 | viewmail.cpp \ |
25 | viewmailbase.cpp \ | 25 | viewmailbase.cpp \ |
26 | mailistviewitem.cpp \ | ||
26 | settingsdialog.cpp \ | 27 | settingsdialog.cpp \ |
27 | statuswidget.cpp \ | 28 | statuswidget.cpp \ |
28 | newmaildir.cpp \ | 29 | newmaildir.cpp \ |
29 | selectstore.cpp | 30 | selectstore.cpp |
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp new file mode 100644 index 0000000..f224dc3 --- a/dev/null +++ b/noncore/net/mail/mailistviewitem.cpp | |||
@@ -0,0 +1,65 @@ | |||
1 | #include "mailistviewitem.h" | ||
2 | #include <qtextstream.h> | ||
3 | #include <qpe/resource.h> | ||
4 | |||
5 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | ||
6 | :QListViewItem(parent,item),mail_data() | ||
7 | { | ||
8 | } | ||
9 | |||
10 | void MailListViewItem::showEntry() | ||
11 | { | ||
12 | if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { | ||
13 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); | ||
14 | } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { | ||
15 | /* I think it looks nicer if there are not such a log of icons but only on mails | ||
16 | replied or new - Alwin*/ | ||
17 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); | ||
18 | } else { | ||
19 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); | ||
20 | } | ||
21 | double s = mail_data.Msgsize(); | ||
22 | int w; | ||
23 | w=0; | ||
24 | |||
25 | while (s>1024) { | ||
26 | s/=1024; | ||
27 | ++w; | ||
28 | if (w>=2) break; | ||
29 | } | ||
30 | |||
31 | QString q=""; | ||
32 | QString fsize=""; | ||
33 | switch(w) { | ||
34 | case 1: | ||
35 | q="k"; | ||
36 | break; | ||
37 | case 2: | ||
38 | q="M"; | ||
39 | break; | ||
40 | default: | ||
41 | break; | ||
42 | } | ||
43 | |||
44 | { | ||
45 | QTextOStream o(&fsize); | ||
46 | if (w>0) o.precision(2); else o.precision(0); | ||
47 | o.setf(QTextStream::fixed); | ||
48 | o << s << " " << q << "Byte"; | ||
49 | } | ||
50 | |||
51 | setText(1,mail_data.getSubject()); | ||
52 | setText(2,mail_data.getFrom()); | ||
53 | setText(3,fsize); | ||
54 | setText(4,mail_data.getDate()); | ||
55 | } | ||
56 | |||
57 | void MailListViewItem::storeData(const RecMail&data) | ||
58 | { | ||
59 | mail_data = data; | ||
60 | } | ||
61 | |||
62 | const RecMail& MailListViewItem::data()const | ||
63 | { | ||
64 | return mail_data; | ||
65 | } | ||
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h index 271f616..3b352a2 100644 --- a/noncore/net/mail/mailistviewitem.h +++ b/noncore/net/mail/mailistviewitem.h | |||
@@ -3,9 +3,8 @@ | |||
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <libmailwrapper/mailtypes.h> | 5 | #include <libmailwrapper/mailtypes.h> |
6 | 6 | ||
7 | |||
8 | class MailListViewItem:public QListViewItem | 7 | class MailListViewItem:public QListViewItem |
9 | { | 8 | { |
10 | public: | 9 | public: |
11 | MailListViewItem(QListView * parent, MailListViewItem * after ); | 10 | MailListViewItem(QListView * parent, MailListViewItem * after ); |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index e16f853..c38392c 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -3,19 +3,14 @@ | |||
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qtextstream.h> | ||
8 | 7 | ||
9 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
10 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
11 | 10 | ||
12 | |||
13 | #include "defines.h" | 11 | #include "defines.h" |
14 | #include "mainwindow.h" | 12 | #include "mainwindow.h" |
15 | #include "viewmail.h" | ||
16 | #include <libmailwrapper/mailtypes.h> | ||
17 | #include "mailistviewitem.h" | ||
18 | 13 | ||
19 | 14 | ||
20 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 15 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
21 | : QMainWindow( parent, name, flags ) | 16 | : QMainWindow( parent, name, flags ) |
@@ -126,16 +121,31 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
126 | SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); | 121 | SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); |
127 | connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 122 | connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
128 | SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); | 123 | SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); |
129 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 124 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
125 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | ||
126 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | ||
127 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | ||
128 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | ||
129 | // Added by Stefan Eilers to allow starting by addressbook.. | ||
130 | // copied from old mail2 | ||
131 | #if !defined(QT_NO_COP) | ||
132 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), | ||
133 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | ||
134 | #endif | ||
130 | 135 | ||
131 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 136 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
132 | } | 137 | } |
133 | 138 | ||
134 | MainWindow::~MainWindow() | 139 | MainWindow::~MainWindow() |
135 | { | 140 | { |
136 | } | 141 | } |
137 | 142 | ||
143 | void MainWindow::appMessage(const QCString &, const QByteArray &) | ||
144 | { | ||
145 | qDebug("appMessage not reached"); | ||
146 | } | ||
147 | |||
138 | void MainWindow::slotAdjustLayout() { | 148 | void MainWindow::slotAdjustLayout() { |
139 | 149 | ||
140 | QWidget *d = QApplication::desktop(); | 150 | QWidget *d = QApplication::desktop(); |
141 | 151 | ||
@@ -163,142 +173,33 @@ void MainWindow::slotAdjustColumns() | |||
163 | void MainWindow::slotEditSettings() | 173 | void MainWindow::slotEditSettings() |
164 | { | 174 | { |
165 | } | 175 | } |
166 | 176 | ||
167 | void MainWindow::slotShowFolders( bool show ) | 177 | void MainWindow::slotShowFolders( bool ) |
168 | { | 178 | { |
169 | qDebug( "Show Folders" ); | 179 | qDebug( "slotShowFolders not reached" ); |
170 | if ( show && folderView->isHidden() ) { | ||
171 | qDebug( "-> showing" ); | ||
172 | folderView->show(); | ||
173 | } else if ( !show && !folderView->isHidden() ) { | ||
174 | qDebug( "-> hiding" ); | ||
175 | folderView->hide(); | ||
176 | } | ||
177 | } | 180 | } |
178 | 181 | ||
179 | void MainWindow::refreshMailView(QList<RecMail>*list) | 182 | void MainWindow::refreshMailView(QList<RecMail>*) |
180 | { | 183 | { |
181 | MailListViewItem*item = 0; | 184 | qDebug( "refreshMailView not reached" ); |
182 | mailView->clear(); | ||
183 | for (unsigned int i = 0; i < list->count();++i) { | ||
184 | item = new MailListViewItem(mailView,item); | ||
185 | item->storeData(*(list->at(i))); | ||
186 | item->showEntry(); | ||
187 | } | ||
188 | } | 185 | } |
189 | void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | 186 | |
187 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) | ||
190 | { | 188 | { |
191 | /* just LEFT button - or tap with stylus on pda */ | 189 | qDebug( "mailLeftClicked not reached" ); |
192 | if (button!=1) return; | ||
193 | if (!item) return; | ||
194 | displayMail(); | ||
195 | } | 190 | } |
196 | 191 | ||
197 | void MainWindow::displayMail() | 192 | void MainWindow::displayMail() |
198 | { | 193 | { |
199 | QListViewItem*item = mailView->currentItem(); | 194 | qDebug("displayMail not reached"); |
200 | if (!item) return; | ||
201 | RecMail mail = ((MailListViewItem*)item)->data(); | ||
202 | RecBody body = folderView->fetchBody(mail); | ||
203 | ViewMail readMail( this ); | ||
204 | readMail.setBody( body ); | ||
205 | readMail.setMail( mail ); | ||
206 | readMail.showMaximized(); | ||
207 | readMail.exec(); | ||
208 | |||
209 | if ( readMail.deleted ) { | ||
210 | folderView->refreshCurrent(); | ||
211 | } else { | ||
212 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); | ||
213 | } | ||
214 | } | 195 | } |
215 | 196 | ||
216 | void MainWindow::slotDeleteMail() | 197 | void MainWindow::slotDeleteMail() |
217 | { | 198 | { |
218 | if (!mailView->currentItem()) return; | 199 | qDebug("deleteMail not reached"); |
219 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | ||
220 | 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 ) { | ||
221 | mail.Wrapper()->deleteMail( mail ); | ||
222 | folderView->refreshCurrent(); | ||
223 | } | ||
224 | } | ||
225 | |||
226 | void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int ) | ||
227 | { | ||
228 | /* just the RIGHT button - or hold on pda */ | ||
229 | if (button!=2) {return;} | ||
230 | qDebug("Event right/hold"); | ||
231 | if (!item) return; | ||
232 | QPopupMenu *m = new QPopupMenu(0); | ||
233 | if (m) { | ||
234 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | ||
235 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | ||
236 | m->setFocus(); | ||
237 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | ||
238 | delete m; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | ||
243 | :QListViewItem(parent,item),mail_data() | ||
244 | { | ||
245 | } | ||
246 | |||
247 | void MailListViewItem::showEntry() | ||
248 | { | ||
249 | if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { | ||
250 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); | ||
251 | } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { | ||
252 | /* I think it looks nicer if there are not such a log of icons but only on mails | ||
253 | replied or new - Alwin*/ | ||
254 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); | ||
255 | } else { | ||
256 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); | ||
257 | } | ||
258 | double s = mail_data.Msgsize(); | ||
259 | int w; | ||
260 | w=0; | ||
261 | |||
262 | while (s>1024) { | ||
263 | s/=1024; | ||
264 | ++w; | ||
265 | if (w>=2) break; | ||
266 | } | ||
267 | |||
268 | QString q=""; | ||
269 | QString fsize=""; | ||
270 | switch(w) { | ||
271 | case 1: | ||
272 | q="k"; | ||
273 | break; | ||
274 | case 2: | ||
275 | q="M"; | ||
276 | break; | ||
277 | default: | ||
278 | break; | ||
279 | } | ||
280 | |||
281 | { | ||
282 | QTextOStream o(&fsize); | ||
283 | if (w>0) o.precision(2); else o.precision(0); | ||
284 | o.setf(QTextStream::fixed); | ||
285 | o << s << " " << q << "Byte"; | ||
286 | } | ||
287 | |||
288 | setText(1,mail_data.getSubject()); | ||
289 | setText(2,mail_data.getFrom()); | ||
290 | setText(3,fsize); | ||
291 | setText(4,mail_data.getDate()); | ||
292 | } | 200 | } |
293 | 201 | ||
294 | void MailListViewItem::storeData(const RecMail&data) | 202 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
295 | { | 203 | { |
296 | mail_data = data; | 204 | qDebug("mailHold not reached"); |
297 | } | 205 | } |
298 | |||
299 | const RecMail& MailListViewItem::data()const | ||
300 | { | ||
301 | return mail_data; | ||
302 | } | ||
303 | |||
304 | |||
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 15d216a..20614cc 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h | |||
@@ -22,8 +22,9 @@ public: | |||
22 | virtual ~MainWindow(); | 22 | virtual ~MainWindow(); |
23 | 23 | ||
24 | public slots: | 24 | public slots: |
25 | virtual void slotAdjustColumns(); | 25 | virtual void slotAdjustColumns(); |
26 | virtual void appMessage(const QCString &msg, const QByteArray &data); | ||
26 | 27 | ||
27 | protected slots: | 28 | protected slots: |
28 | virtual void slotShowFolders( bool show ); | 29 | virtual void slotShowFolders( bool show ); |
29 | virtual void refreshMailView(QList<RecMail>*); | 30 | virtual void refreshMailView(QList<RecMail>*); |
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index c888708..dee3f70 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -4,31 +4,22 @@ | |||
4 | #include "editaccounts.h" | 4 | #include "editaccounts.h" |
5 | #include "composemail.h" | 5 | #include "composemail.h" |
6 | #include <libmailwrapper/smtpwrapper.h> | 6 | #include <libmailwrapper/smtpwrapper.h> |
7 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
8 | #include <qpe/resource.h> | ||
8 | #include <qaction.h> | 9 | #include <qaction.h> |
9 | #include <qapplication.h> | 10 | #include <qapplication.h> |
11 | #include <libmailwrapper/mailtypes.h> | ||
12 | #include "mailistviewitem.h" | ||
13 | #include "viewmail.h" | ||
14 | #include "selectstore.h" | ||
10 | 15 | ||
11 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | 16 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) |
12 | : MainWindow( parent, name, flags ) | 17 | : MainWindow( parent, name, flags ) |
13 | { | 18 | { |
14 | settings = new Settings(); | 19 | settings = new Settings(); |
15 | 20 | ||
16 | folderView->populate( settings->getAccounts() ); | 21 | folderView->populate( settings->getAccounts() ); |
17 | |||
18 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | ||
19 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | ||
20 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | ||
21 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | ||
22 | // Added by Stefan Eilers to allow starting by addressbook.. | ||
23 | // copied from old mail2 | ||
24 | #if !defined(QT_NO_COP) | ||
25 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), | ||
26 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | ||
27 | #endif | ||
28 | |||
29 | |||
30 | |||
31 | } | 22 | } |
32 | 23 | ||
33 | OpieMail::~OpieMail() | 24 | OpieMail::~OpieMail() |
34 | { | 25 | { |
@@ -117,4 +108,104 @@ void OpieMail::slotEditAccounts() | |||
117 | 108 | ||
118 | folderView->populate( settings->getAccounts() ); | 109 | folderView->populate( settings->getAccounts() ); |
119 | } | 110 | } |
120 | 111 | ||
112 | void OpieMail::displayMail() | ||
113 | { | ||
114 | QListViewItem*item = mailView->currentItem(); | ||
115 | if (!item) return; | ||
116 | RecMail mail = ((MailListViewItem*)item)->data(); | ||
117 | RecBody body = folderView->fetchBody(mail); | ||
118 | ViewMail readMail( this ); | ||
119 | readMail.setBody( body ); | ||
120 | readMail.setMail( mail ); | ||
121 | readMail.showMaximized(); | ||
122 | readMail.exec(); | ||
123 | |||
124 | if ( readMail.deleted ) { | ||
125 | folderView->refreshCurrent(); | ||
126 | } else { | ||
127 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | void OpieMail::slotDeleteMail() | ||
132 | { | ||
133 | if (!mailView->currentItem()) return; | ||
134 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | ||
135 | 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 ) { | ||
136 | mail.Wrapper()->deleteMail( mail ); | ||
137 | folderView->refreshCurrent(); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | ||
142 | { | ||
143 | /* just the RIGHT button - or hold on pda */ | ||
144 | if (button!=2) {return;} | ||
145 | qDebug("Event right/hold"); | ||
146 | if (!item) return; | ||
147 | QPopupMenu *m = new QPopupMenu(0); | ||
148 | if (m) { | ||
149 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | ||
150 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | ||
151 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | ||
152 | m->setFocus(); | ||
153 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | ||
154 | delete m; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | void OpieMail::slotShowFolders( bool show ) | ||
159 | { | ||
160 | qDebug( "Show Folders" ); | ||
161 | if ( show && folderView->isHidden() ) { | ||
162 | qDebug( "-> showing" ); | ||
163 | folderView->show(); | ||
164 | } else if ( !show && !folderView->isHidden() ) { | ||
165 | qDebug( "-> hiding" ); | ||
166 | folderView->hide(); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | void OpieMail::refreshMailView(QList<RecMail>*list) | ||
171 | { | ||
172 | MailListViewItem*item = 0; | ||
173 | mailView->clear(); | ||
174 | for (unsigned int i = 0; i < list->count();++i) { | ||
175 | item = new MailListViewItem(mailView,item); | ||
176 | item->storeData(*(list->at(i))); | ||
177 | item->showEntry(); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | ||
182 | { | ||
183 | /* just LEFT button - or tap with stylus on pda */ | ||
184 | if (button!=1) return; | ||
185 | if (!item) return; | ||
186 | displayMail(); | ||
187 | } | ||
188 | |||
189 | void OpieMail::slotMoveCopyMail() | ||
190 | { | ||
191 | if (!mailView->currentItem()) return; | ||
192 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | ||
193 | AbstractMail*targetMail = 0; | ||
194 | QString targetFolder = ""; | ||
195 | Selectstore sels; | ||
196 | folderView->setupFolderselect(&sels); | ||
197 | if (!sels.exec()) return; | ||
198 | targetMail = sels.currentMail(); | ||
199 | targetFolder = sels.currentFolder(); | ||
200 | if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || | ||
201 | targetFolder.isEmpty()) { | ||
202 | return; | ||
203 | } | ||
204 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { | ||
205 | QMessageBox::critical(0,tr("Error creating new Folder"), | ||
206 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | ||
207 | return; | ||
208 | } | ||
209 | mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | ||
210 | folderView->refreshCurrent(); | ||
211 | } | ||
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h index 69b8d43..5821856 100644 --- a/noncore/net/mail/opiemail.h +++ b/noncore/net/mail/opiemail.h | |||
@@ -22,8 +22,16 @@ protected slots: | |||
22 | virtual void slotSendQueued(); | 22 | virtual void slotSendQueued(); |
23 | virtual void slotSearchMails(); | 23 | virtual void slotSearchMails(); |
24 | virtual void slotEditSettings(); | 24 | virtual void slotEditSettings(); |
25 | virtual void slotEditAccounts(); | 25 | virtual void slotEditAccounts(); |
26 | virtual void displayMail(); | ||
27 | virtual void slotDeleteMail(); | ||
28 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | ||
29 | virtual void slotShowFolders( bool show ); | ||
30 | virtual void refreshMailView(QList<RecMail>*); | ||
31 | virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); | ||
32 | virtual void slotMoveCopyMail(); | ||
33 | |||
26 | private: | 34 | private: |
27 | Settings *settings; | 35 | Settings *settings; |
28 | 36 | ||
29 | }; | 37 | }; |