-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 28 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 39 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 12 |
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 @@ -66,25 +66,17 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 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 ); @@ -94,24 +86,39 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 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 ); @@ -144,17 +151,18 @@ void MainWindow::refreshMailView(QList<RecMail>*list) 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() { } 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 @@ -21,21 +21,22 @@ public: 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 @@ -18,24 +18,25 @@ AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) 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) @@ -49,35 +50,49 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) // _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(); } 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,13 +1,14 @@ #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: @@ -44,17 +45,17 @@ class ViewMail : public ViewMailBase 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(); @@ -63,13 +64,22 @@ protected slots: // 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 |