-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 32 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 4 |
2 files changed, 29 insertions, 7 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index c115b32..93d80d9 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -1,20 +1,21 @@ #include <qlabel.h> #include <qvbox.h> #include <qheader.h> #include <qtimer.h> #include <qlayout.h> #include <opie2/odebug.h> #include <qpe/qpeapplication.h> +#include <qpe/qcopenvelope_qws.h> #include "defines.h" #include "mainwindow.h" using namespace Opie::Core; MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name, flags ) { setCaption( tr( "Mail" ) ); setToolBarsMovable( false ); @@ -77,25 +78,24 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , 0, 0, this ); editAccounts->addTo( settingsMenu ); //setCentralWidget( view ); QVBox* wrapperBox = new QVBox( this ); setCentralWidget( wrapperBox ); QWidget *view = new QWidget( wrapperBox ); - layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); folderView = new AccountView( view ); folderView->header()->hide(); folderView->setRootIsDecorated( true ); folderView->addColumn( tr( "Mailbox" ) ); layout->addWidget( folderView ); mailView = new QListView( view ); mailView->addColumn( "" ); mailView->addColumn( tr( "Subject" ),QListView::Manual ); @@ -104,67 +104,85 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) mailView->addColumn( tr( "Date" )); mailView->setAllColumnsShowFocus(true); mailView->setShowSortIndicator(true); mailView->setSorting(4,false); statusWidget = new StatusWidget( wrapperBox ); statusWidget->hide(); layout->addWidget( mailView ); layout->setStretchFactor( folderView, 1 ); layout->setStretchFactor( mailView, 2 ); + m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90); + slotAdjustLayout(); QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), this,SLOT(refreshMailView(const QValueList<RecMailP>&))); connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); // Added by Stefan Eilers to allow starting by addressbook.. // copied from old mail2 #if !defined(QT_NO_COP) connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); + m_sysChannel = new QCopChannel( "QPE/System", this ); + connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), + this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); #endif QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); } MainWindow::~MainWindow() { } +void MainWindow::systemMessage( const QCString& msg, const QByteArray& data ) +{ + int _newrotation; + QDataStream stream( data, IO_ReadOnly ); + if ( msg == "setCurrentRotation(int)" ) + { + stream >> _newrotation; + if (m_Rotate != _newrotation) { + slotAdjustLayout(); + m_Rotate = _newrotation; + } + } +} + void MainWindow::appMessage(const QCString &, const QByteArray &) { odebug << "appMessage not reached" << oendl; } void MainWindow::slotAdjustLayout() { - QWidget *d = QApplication::desktop(); - - if ( d->width() < d->height() ) { - layout->setDirection( QBoxLayout::TopToBottom ); + QWidget *d = QApplication::desktop(); + if ( d->width() < d->height() ) { + layout->setDirection( QBoxLayout::TopToBottom ); } else { - layout->setDirection( QBoxLayout::LeftToRight ); - } + layout->setDirection( QBoxLayout::LeftToRight ); + } } void MainWindow::slotAdjustColumns() { bool hidden = folderView->isHidden(); if ( hidden ) folderView->show(); folderView->setColumnWidth( 0, folderView->visibleWidth() ); if ( hidden ) folderView->hide(); mailView->setColumnWidth( 0, 10 ); mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); mailView->setColumnWidth( 2, 80 ); diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 8d004c6..8cec888 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h @@ -6,51 +6,55 @@ #include <qaction.h> #include <qtoolbar.h> #include <qmenubar.h> #include "accountview.h" #include "statuswidget.h" #include <libmailwrapper/mailtypes.h> #include <opie2/osmartpointer.h> class RecMail; +class QCopChannel; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); virtual ~MainWindow(); public slots: virtual void slotAdjustColumns(); virtual void appMessage(const QCString &msg, const QByteArray &data); virtual void slotComposeMail(); + virtual void systemMessage( const QCString&, const QByteArray& ); protected slots: virtual void slotSendQueued(); virtual void slotEditAccounts(); virtual void slotShowFolders( bool show ); virtual void refreshMailView(const QValueList<RecMailP>&); virtual void displayMail(); virtual void slotDeleteMail(); virtual void mailHold(int, QListViewItem *,const QPoint&,int); virtual void slotAdjustLayout(); virtual void slotEditSettings(); virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); protected: QToolBar *toolBar; StatusWidget *statusWidget; QMenuBar *menuBar; QPopupMenu *mailMenu, *settingsMenu; QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, *editSettings, *editAccounts, *syncFolders; AccountView *folderView; QListView *mailView; QBoxLayout *layout; + int m_Rotate; + QCopChannel* m_sysChannel; }; #endif |