summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-12-09 18:02:33 (UTC)
committer harlekin <harlekin>2003-12-09 18:02:33 (UTC)
commit0b7d74768f00be986f44bfbd61a6342fc854cc3a (patch) (side-by-side diff)
tree2e314f0d73e3c720783618870fb6d2e16b4acf3e
parenta30efc4ca72e7689ee35b178d28db82054431fe9 (diff)
downloadopie-0b7d74768f00be986f44bfbd61a6342fc854cc3a.zip
opie-0b7d74768f00be986f44bfbd61a6342fc854cc3a.tar.gz
opie-0b7d74768f00be986f44bfbd61a6342fc854cc3a.tar.bz2
more updates
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp28
-rw-r--r--noncore/net/mail/mainwindow.h3
-rw-r--r--noncore/net/mail/viewmail.cpp39
-rw-r--r--noncore/net/mail/viewmail.h12
4 files changed, 58 insertions, 24 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index b25db97..f19f93d 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,177 +1,185 @@
#include <qlabel.h>
#include <qvbox.h>
#include <qheader.h>
#include <qtimer.h>
#include <qlayout.h>
#include <qpe/qpeapplication.h>
#include "defines.h"
#include "mainwindow.h"
#include "viewmail.h"
#include "mailtypes.h"
#include "mailistviewitem.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
: QMainWindow( parent, name, flags )
{
setCaption( tr( "Opie-Mail" ) );
setToolBarsMovable( false );
toolBar = new QToolBar( this );
menuBar = new QMenuBar( toolBar );
mailMenu = new QPopupMenu( menuBar );
menuBar->insertItem( tr( "Mail" ), mailMenu );
settingsMenu = new QPopupMenu( menuBar );
menuBar->insertItem( tr( "Settings" ), settingsMenu );
addToolBar( toolBar );
toolBar->setHorizontalStretchable( true );
QLabel *spacer = new QLabel( toolBar );
spacer->setBackgroundMode( QWidget::PaletteButton );
toolBar->setStretchableWidget( spacer );
composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
0, 0, this );
composeMail->addTo( toolBar );
composeMail->addTo( mailMenu );
sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
0, 0, this );
sendQueued->addTo( toolBar );
sendQueued->addTo( mailMenu );
syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
0, 0, this );
syncFolders->addTo( toolBar );
syncFolders->addTo( mailMenu );
showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
0, 0, this, 0, true );
showFolders->addTo( toolBar );
showFolders->addTo( mailMenu );
connect(showFolders, SIGNAL( toggled( bool ) ),
SLOT( slotShowFolders( bool ) ) );
searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS,
0, 0, this );
searchMails->addTo( toolBar );
searchMails->addTo( mailMenu );
editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
0, 0, this );
editSettings->addTo( settingsMenu );
editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
0, 0, this );
editAccounts->addTo( settingsMenu );
QWidget *view = new QWidget( this );
setCentralWidget( view );
-
- QWidget *d = QApplication::desktop();
- QBoxLayout *layout;
-
- if ( d->width() < d->height() ) {
- layout = new QVBoxLayout( view );
- } else {
- layout = new QHBoxLayout( view );
- }
+ layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
folderView = new AccountView( view );
folderView->header()->hide();
folderView->addColumn( tr( "Mailbox" ) );
folderView->hide();
layout->addWidget( folderView );
mailView = new QListView( view );
mailView->addColumn( tr( "Subject" ),QListView::Manual );
mailView->addColumn( tr( "Sender" ),QListView::Manual );
mailView->addColumn( tr( "Date" ));
mailView->setAllColumnsShowFocus(true);
mailView->setSorting(-1);
layout->addWidget( mailView );
layout->setStretchFactor( folderView, 1 );
layout->setStretchFactor( mailView, 2 );
+ slotAdjustLayout();
+
connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
SLOT( displayMail( QListViewItem * ) ) );
connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
}
+
+void MainWindow::slotAdjustLayout() {
+
+ QWidget *d = QApplication::desktop();
+
+ if ( d->width() < d->height() ) {
+ layout->setDirection( QBoxLayout::TopToBottom );
+ } else {
+ layout->setDirection( QBoxLayout::LeftToRight );
+ }
+ delete d;
+}
+
void MainWindow::slotAdjustColumns()
{
bool hidden = folderView->isHidden();
if ( hidden ) folderView->show();
folderView->setColumnWidth( 0, folderView->visibleWidth() );
if ( hidden ) folderView->hide();
mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 );
mailView->setColumnWidth( 1, 80 );
mailView->setColumnWidth( 2, 50 );
}
void MainWindow::slotShowFolders( bool show )
{
qDebug( "Show Folders" );
if ( show && folderView->isHidden() ) {
qDebug( "-> showing" );
folderView->show();
} else if ( !show && !folderView->isHidden() ) {
qDebug( "-> hiding" );
folderView->hide();
}
}
void MainWindow::refreshMailView(QList<RecMail>*list)
{
MailListViewItem*item = 0;
mailView->clear();
for (unsigned int i = 0; i < list->count();++i) {
item = new MailListViewItem(mailView,item);
item->storeData(*(list->at(i)));
item->showEntry();
}
}
void MainWindow::displayMail(QListViewItem*item)
{
if (!item) return;
qDebug("View mail");
RecMail mail = ((MailListViewItem*)item)->data();
RecBody body = folderView->fetchBody(mail);
ViewMail readMail( this );
- readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body.Bodytext() );
+
+ readMail.setMailInfo( mail.getFrom(), mail.To(), mail.getSubject(), mail.CC(), mail.Bcc(), mail.getDate(), body.Bodytext() );
readMail.showMaximized();
readMail.exec();
}
MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after )
:QListViewItem(parent,after),mail_data()
{
}
void MailListViewItem::showEntry()
{
setText(0,mail_data.getSubject());
setText(1,mail_data.getFrom());
setText(2,mail_data.getDate());
}
void MailListViewItem::storeData(const RecMail&data)
{
mail_data = data;
}
const RecMail& MailListViewItem::data()const
{
return mail_data;
}
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 6c87261..6c1cda0 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -1,41 +1,42 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qlistview.h>
#include <qaction.h>
#include <qtoolbar.h>
#include <qmenubar.h>
#include "accountview.h"
class RecMail;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
public slots:
void slotAdjustColumns();
protected slots:
virtual void slotShowFolders( bool show );
virtual void refreshMailView(QList<RecMail>*);
virtual void displayMail(QListViewItem*);
+ void slotAdjustLayout();
protected:
QToolBar *toolBar;
QMenuBar *menuBar;
QPopupMenu *mailMenu, *settingsMenu;
QAction *composeMail, *sendQueued, *showFolders, *searchMails,
*editSettings, *editAccounts, *syncFolders;
AccountView *folderView;
QListView *mailView;
-
+ QBoxLayout *layout;
};
#endif
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index b648b34..cba9948 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1,216 +1,231 @@
#include <qtextbrowser.h>
#include <qmessagebox.h>
#include <qaction.h>
#include <qapplication.h>
//#include "mailfactory.h"
//#include "composer.h"
#include "viewmail.h"
AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore)
: QListViewItem(parent), _attachItemStore(attachItemStore)
{
setText(0, _attachItemStore.mimeType());
setText(1, _attachItemStore.fileName());
setText(2, _attachItemStore.description());
}
AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore)
: QListViewItem(parent), _attachItemStore(attachItemStore)
{
setText(0, _attachItemStore.mimeType());
setText(1, _attachItemStore.fileName());
setText(2, _attachItemStore.description());
}
-void ViewMail::setMailInfo( const QString & from, const QString & to, const QString & subject, const QString & cc, const QString & bcc, const QString & bodytext ) {
+void ViewMail::setMailInfo( const QString & from, const QStringList & to, const QString & subject, const QStringList & cc, const QStringList & bcc, const QString & date, const QString & bodytext ) {
m_mail[0] = from;
-m_mail[1] = to;
-m_mail[2] = subject;
-m_mail[3] = cc;
-m_mail[4] = bcc;
-m_mail[5] = bodytext;
+m_mail2[0] = to;
+m_mail[1] = subject;
+m_mail2[1] = cc;
+m_mail2[2] = bcc;
+m_mail[2] = bodytext;
+m_mail[3] = date;
setText();
}
ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
: ViewMailBase(parent, name, fl), _inLoop(false)
{
_gotBody = false;
connect(reply, SIGNAL(activated()), SLOT(slotReply()));
connect(forward, SIGNAL(activated()), SLOT(slotForward()));
attachments->setEnabled(_gotBody);
// _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid()));
// connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &)));
}
void ViewMail::setText()
{
+ QString toString;
+ QString ccString;
+ QString bccString;
+
+ for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) {
+ toString += (*it);
+ }
+ for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) {
+ ccString += (*it);
+ }
+ for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) {
+ bccString += (*it);
+ }
+
setCaption( caption().arg( m_mail[0] ) );
_mailHtml = tr(
"<html><body>"
"<div align=center><b>%1</b></div>"
"<b>From:</b> %2<br>"
"<b>To:</b> %3<br>"
"%4"
"%5"
"<b>Date:</b> %6<hr>"
"<font face=fixed>%7</font>")
- .arg( deHtml( m_mail[2] ) )
- .arg( deHtml( m_mail[0] ) )
.arg( deHtml( m_mail[1] ) )
- .arg( tr("<b>Cc:</b> %1<br>").arg( deHtml( m_mail[3] ) ) )
- .arg( tr("<b>Bcc:</b> %1<br>").arg( deHtml( m_mail[4] ) ) )
- .arg( tr("(no date)" ) )
+ .arg( deHtml( m_mail[0] ) )
+ .arg( deHtml( toString ) )
+ .arg( tr("<b>Cc:</b> %1<br>").arg( deHtml( ccString ) ) )
+ .arg( tr("<b>Bcc:</b> %1<br>").arg( deHtml( bccString ) ) )
+ .arg( m_mail[3] )
.arg("%1");
- browser->setText( QString(_mailHtml) + deHtml( m_mail[5] ) );
+ browser->setText( QString(_mailHtml) + deHtml( m_mail[2] ) );
}
ViewMail::~ViewMail()
{
hide();
}
void ViewMail::hide()
{
QWidget::hide();
if (_inLoop) {
_inLoop = false;
qApp->exit_loop();
}
}
void ViewMail::exec()
{
show();
if (!_inLoop) {
_inLoop = true;
qApp->enter_loop();
}
}
QString ViewMail::deHtml(const QString &string)
{
QString string_ = string;
string_.replace(QRegExp("&"), "&amp;");
string_.replace(QRegExp("<"), "&lt;");
string_.replace(QRegExp(">"), "&gt;");
string_.replace(QRegExp("\\n"), "<br>");
return string_;
}
void ViewMail::slotReply()
{
if (!_gotBody) {
QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
return;
}
QString rtext;
// rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
// .arg(_mail.envelope().from()[0].toString())
// .arg(_mail.envelope().mailDate());
// QString text = _mail.bodyPart(1).data();
// QStringList lines = QStringList::split(QRegExp("\\n"), text);
QStringList::Iterator it;
// for (it = lines.begin(); it != lines.end(); it++) {
// rtext += "> " + *it + "\n";
// }
rtext += "\n";
QString prefix;
// if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = "";
// else prefix = "Re: "; // no i18n on purpose
// SendMail sendMail;
// sendMail.setTo(_mail.envelope().from()[0].toString());
// sendMail.setSubject(prefix + _mail.envelope().subject());
// sendMail.setInReplyTo(_mail.envelope().messageId());
// sendMail.setMessage(rtext);
// Composer composer(this, 0, true);
// composer.setSendMail(sendMail);
// composer.showMaximized();
// composer.exec();
}
void ViewMail::slotForward()
{
if (!_gotBody) {
QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
return;
}
QString ftext;
/* ftext += QString("\n----- Forwarded message from %1 -----\n\n")
.arg(_mail.envelope().from()[0].toString());
if (!_mail.envelope().mailDate().isNull())
ftext += QString("Date: %1\n")
.arg(_mail.envelope().mailDate());
if (!_mail.envelope().from()[0].toString().isNull())
ftext += QString("From: %1\n")
.arg(_mail.envelope().from()[0].toString());
if (!_mail.envelope().to().toString().isNull())
ftext += QString("To: %1\n")
.arg(_mail.envelope().to().toString());
if (!_mail.envelope().cc().toString().isNull())
ftext += QString("Cc: %1\n")
.arg(_mail.envelope().cc().toString());
if (!_mail.envelope().bcc().toString().isNull())
ftext += QString("Bcc: %1\n")
.arg(_mail.envelope().bcc().toString());
if (!_mail.envelope().subject().isNull())
ftext += QString("Subject: %1\n")
.arg(_mail.envelope().subject());
ftext += QString("\n%1\n")
.arg(_mail.bodyPart(1).data());
ftext += QString("----- End forwarded message -----\n");
*/
/*
SendMail sendMail;
sendMail.setSubject("Fwd: " + _mail.envelope().subject());
sendMail.setMessage(ftext);
Composer composer(this, 0, true);
composer.setSendMail(sendMail);
composer.showMaximized();
composer.exec();
*/
}
/*
void ViewMail::slotIMAPUid(IMAPResponse &response)
{
disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &)));
if (response.statusResponse().status() == IMAPResponseEnums::OK) {
QValueList<IMAPResponseBodyPart> bodyParts;
bodyParts.append(response.FETCH()[0].bodyPart(0));
_mail.setBodyParts(bodyParts);
browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data())));
// fillList(response.FETCH()[0].bodyStructure());
_gotBody = true;
} else {
QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok"));
}
}
*/
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index 9d3c6e4..615939a 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -1,75 +1,85 @@
#ifndef VIEWMAIL_H
#define VIEWMAIL_H
#include <qlistview.h>
#include <qmap.h>
+#include <qstringlist.h>
#include "viewmailbase.h"
//#include "imapresponse.h"
//#include "mailtable.h"
class AttachItemStore
{
public:
void setMimeType(QString mimeType) { _mimeType = mimeType; }
QString mimeType() { return _mimeType; }
void setFileName(QString fileName) { _fileName = fileName; }
QString fileName() { return _fileName; }
void setDescription(QString description) { _description = description; }
QString description() { return _description; }
void setPartNum(QString partNum) { _partNum = partNum; }
QString partNum() { return _partNum; }
private:
QString _mimeType, _fileName, _description, _partNum;
};
class AttachItem : public QListViewItem
{
public:
AttachItem(QListView *parent, AttachItemStore &attachment);
AttachItem(QListViewItem *parent, AttachItemStore &attachment);
AttachItemStore attachItemStore() { return _attachItemStore; }
private:
AttachItemStore _attachItemStore;
};
class ViewMail : public ViewMailBase
{
Q_OBJECT
public:
ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal);
~ViewMail();
void hide();
void exec();
static QString appName() { return QString::fromLatin1("mail"); }
- void setMailInfo( const QString & from, const QString & to, const QString & subject, const QString & cc, const QString & bcc, const QString & bodytext );
+ void setMailInfo( const QString & from, const QStringList & to, const QString & subject, const QStringList & cc, const QStringList & bcc,const QString & date, const QString & bodytext );
protected:
// void fillList(IMAPResponseBODYSTRUCTURE &structure);
QString deHtml(const QString &string);
protected slots:
void slotReply();
void slotForward();
void setText();
// void slotIMAPUid(IMAPResponse &response);
private:
bool _inLoop;
// IMAPResponseFETCH _mail;
// IMAPHandler *_handler;
QString _mailHtml;
bool _gotBody;
+
+ // 0 from
+ // 1 subject
+ // 2 bodytext
+ // 3 date
QMap <int,QString> m_mail;
+ // 0 to
+ // 1 cc
+ // 2 bcc
+ QMap <int,QStringList> m_mail2;
};
#endif