author | alwin <alwin> | 2004-01-08 14:04:54 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-08 14:04:54 (UTC) |
commit | ab6a32266c8fb625e782c601c9729af7f98904f6 (patch) (unidiff) | |
tree | 1457c421109359bdaa50082f2640d33ac4d74cc2 /noncore/net/mail/mainwindow.cpp | |
parent | b85bc4484bcc0a53557b4759c3e9e58dc9059138 (diff) | |
download | opie-ab6a32266c8fb625e782c601c9729af7f98904f6.zip opie-ab6a32266c8fb625e782c601c9729af7f98904f6.tar.gz opie-ab6a32266c8fb625e782c601c9729af7f98904f6.tar.bz2 |
- store single message to another folder implemented
- cleaned code in mainwindow and opiemail.cpp
Diffstat (limited to 'noncore/net/mail/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 151 |
1 files changed, 26 insertions, 125 deletions
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 | |||
@@ -1,23 +1,18 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qvbox.h> | 2 | #include <qvbox.h> |
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 ) |
22 | { | 17 | { |
23 | 18 | ||
@@ -124,20 +119,35 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
124 | 119 | ||
125 | connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, | 120 | connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, |
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 | ||
142 | if ( d->width() < d->height() ) { | 152 | if ( d->width() < d->height() ) { |
143 | layout->setDirection( QBoxLayout::TopToBottom ); | 153 | layout->setDirection( QBoxLayout::TopToBottom ); |
@@ -161,144 +171,35 @@ void MainWindow::slotAdjustColumns() | |||
161 | } | 171 | } |
162 | 172 | ||
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 | |||