Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mainwindow.cpp

Go to the documentation of this file.
00001 #include "defines.h"
00002 #include "mainwindow.h"
00003 
00004 /* OPIE */
00005 #include <opie2/odebug.h>
00006 #include <opie2/oresource.h>
00007 #include <qpe/qpeapplication.h>
00008 #include <qpe/qcopenvelope_qws.h>
00009 using namespace Opie::Core;
00010 
00011 /* QT */
00012 #include <qlabel.h>
00013 #include <qvbox.h>
00014 #include <qheader.h>
00015 #include <qtimer.h>
00016 #include <qlayout.h>
00017 
00018 MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
00019     : QMainWindow( parent, name, flags )
00020 {
00021     setCaption( tr( "Mail" ) );
00022     setToolBarsMovable( false );
00023 
00024     toolBar = new QToolBar( this );
00025     menuBar = new QMenuBar( toolBar );
00026 
00027     mailMenu = new QPopupMenu( menuBar );
00028     menuBar->insertItem( tr( "Mail" ), mailMenu );
00029 
00030     settingsMenu = new QPopupMenu( menuBar );
00031     menuBar->insertItem( tr( "Settings" ), settingsMenu );
00032 
00033     if (QApplication::desktop()->width()<330) {
00034         serverMenu = new QPopupMenu( mailMenu );
00035         folderMenu = new QPopupMenu( mailMenu );
00036         m_ServerMenuId = mailMenu->insertItem( tr( "Server" ), serverMenu );
00037         m_FolderMenuId = mailMenu->insertItem( tr( "Folder" ), folderMenu );
00038     } else {
00039         serverMenu = new QPopupMenu( menuBar );
00040         folderMenu = new QPopupMenu( menuBar );
00041         m_FolderMenuId = menuBar->insertItem( tr( "Folder" ), folderMenu );
00042         m_ServerMenuId = menuBar->insertItem( tr( "Server" ), serverMenu );
00043     }
00044     serverMenu->insertItem(tr("Disconnect"),SERVER_MENU_DISCONNECT);
00045     serverMenu->insertItem(tr("Set on/offline"),SERVER_MENU_OFFLINE);
00046     serverMenu->insertSeparator();
00047     serverMenu->insertItem(tr("Refresh folder list"),SERVER_MENU_REFRESH_FOLDER);
00048     serverMenu->insertItem(tr("Create new folder"),SERVER_MENU_CREATE_FOLDER);
00049     serverMenu->insertSeparator();
00050     serverMenu->insertItem(tr("(Un-)Subscribe groups"),SERVER_MENU_SUBSCRIBE);
00051 
00052     folderMenu->insertItem(tr("Refresh headerlist"),FOLDER_MENU_REFRESH_HEADER);
00053     folderMenu->insertItem(tr("Delete all mails"),FOLDER_MENU_DELETE_ALL_MAILS);
00054     folderMenu->insertItem(tr("New subfolder"),FOLDER_MENU_NEW_SUBFOLDER);
00055     folderMenu->insertItem(tr("Delete folder"),FOLDER_MENU_DELETE_FOLDER);
00056     folderMenu->insertItem(tr("Move/Copie all mails"),FOLDER_MENU_MOVE_MAILS);
00057     menuBar->setItemEnabled(m_ServerMenuId,false);
00058     menuBar->setItemEnabled(m_FolderMenuId,false);
00059 
00060     addToolBar( toolBar );
00061     toolBar->setHorizontalStretchable( true );
00062 
00063     QLabel *spacer = new QLabel( toolBar );
00064     spacer->setBackgroundMode( QWidget::PaletteButton );
00065     toolBar->setStretchableWidget( spacer );
00066 
00067     readMail = new QAction(tr("Read current mail"),ICON_READMAIL,0,0,this);
00068     readMail->addTo(toolBar);
00069     readMail->addTo(mailMenu);
00070     connect(readMail,SIGNAL(activated()),this,SLOT(displayMail()));
00071 
00072     composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
00073                                0, 0, this );
00074     composeMail->addTo( toolBar );
00075     composeMail->addTo( mailMenu );
00076 
00077 
00078     sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
00079                               0, 0, this );
00080     sendQueued->addTo( toolBar );
00081     sendQueued->addTo( mailMenu );
00082 
00083     /*
00084     syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
00085                                0, 0, this );
00086     syncFolders->addTo( toolBar );
00087     syncFolders->addTo( mailMenu );
00088     */
00089 
00090     showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
00091                                0, 0, this, 0, true );
00092     showFolders->addTo( toolBar );
00093     showFolders->addTo( mailMenu );
00094     showFolders->setOn( true );
00095     connect(showFolders, SIGNAL( toggled(bool) ),
00096             SLOT( slotShowFolders(bool) ) );
00097 
00098     /*
00099     searchMails = new QAction( tr( "Search mails" ), OResource::loadPixmap("find", OResource::SmallIcon ),
00100                                0, 0, this );
00101     searchMails->addTo( toolBar );
00102     searchMails->addTo( mailMenu );
00103     */
00104 
00105     deleteMails = new QAction(tr("Delete Mail"), OResource::loadPixmap("trash", OResource::SmallIcon ), 0, 0, this);
00106     deleteMails->addTo( toolBar );
00107     deleteMails->addTo( mailMenu );
00108     connect( deleteMails, SIGNAL( activated() ),
00109              SLOT( slotDeleteMail() ) );
00110 
00111     editSettings = new QAction( tr( "Edit settings" ), OResource::loadPixmap("SettingsIcon", OResource::SmallIcon ) ,
00112                                 0, 0, this );
00113     editSettings->addTo( settingsMenu );
00114     connect( editSettings, SIGNAL( activated() ),
00115              SLOT( slotEditSettings() ) );
00116     editAccounts = new QAction( tr( "Configure accounts" ), OResource::loadPixmap("mail/editaccounts", OResource::SmallIcon  ) ,
00117                                 0, 0, this );
00118     editAccounts->addTo( settingsMenu );
00119 
00120 
00121     QWidget *view = new QWidget( this );
00122     setCentralWidget( view );
00123     layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
00124 
00125     folderView = new AccountView( view );
00126     folderView->header()->hide();
00127     folderView->setRootIsDecorated( true );
00128     folderView->addColumn( tr( "Mailbox" ) );
00129     connect(folderView,SIGNAL(serverSelected(int)),this,SLOT(serverSelected(int)));
00130     connect(serverMenu,SIGNAL(activated(int)),folderView,SLOT(slotContextMenu(int)));
00131     connect(folderMenu,SIGNAL(activated(int)),folderView,SLOT(slotContextMenu(int)));
00132     connect(this,SIGNAL(settingsChanged()),folderView,SLOT(readSettings()));
00133 
00134 
00135     layout->addWidget( folderView );
00136 
00137     mailView = new QListView( view );
00138     mailView->addColumn( "" );
00139     mailView->addColumn( tr( "Subject" ),QListView::Manual );
00140     mailView->addColumn( tr( "Sender" ),QListView::Manual );
00141     mailView->addColumn( tr( "Size" ),QListView::Manual);
00142     mailView->addColumn( tr( "Date" ));
00143     mailView->setAllColumnsShowFocus(true);
00144     mailView->setShowSortIndicator(true);
00145     mailView->setSorting(4,false);
00146 
00147     layout->addWidget( mailView );
00148     layout->setStretchFactor( folderView, 1 );
00149     layout->setStretchFactor( mailView, 2 );
00150 
00151     m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90);
00152 
00153     slotAdjustLayout();
00154 
00155     QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
00156     QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
00157 
00158     connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this,
00159              SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) );
00160     connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
00161              SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
00162 
00163     connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
00164             this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
00165 
00166     connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
00167     connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
00168 
00169 //    connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
00170     connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
00171     // Added by Stefan Eilers to allow starting by addressbook..
00172     // copied from old mail2
00173 
00174 #if !defined(QT_NO_COP)
00175     connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
00176              this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
00177     m_sysChannel = new QCopChannel( "QPE/System", this );
00178     connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
00179         this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
00180 #endif
00181 
00182     QTimer::singleShot( 10, this, SLOT( slotAdjustColumns() ) );
00183 }
00184 
00185 MainWindow::~MainWindow()
00186 {
00187 }
00188 
00189 void MainWindow::serverSelected(int)
00190 {
00191     odebug << "slotShowFolders not reached" << oendl;
00192 }
00193 
00194 void MainWindow::systemMessage( const QCString& msg, const QByteArray& data )
00195 {
00196     int _newrotation;
00197     QDataStream stream( data, IO_ReadOnly );
00198     if ( msg == "setCurrentRotation(int)" )
00199     {
00200         stream >> _newrotation;
00201         if (m_Rotate != _newrotation) {
00202             slotAdjustLayout();
00203             m_Rotate = _newrotation;
00204         }
00205     }
00206 }
00207 
00208 void MainWindow::appMessage(const QCString &, const QByteArray &)
00209 {
00210     odebug << "appMessage not reached" << oendl;
00211 }
00212 
00213 void MainWindow::slotAdjustLayout() {
00214 
00215     QWidget *d = QApplication::desktop();
00216     if ( d->width() < d->height() ) {
00217         layout->setDirection( QBoxLayout::TopToBottom );
00218     } else {
00219         layout->setDirection( QBoxLayout::LeftToRight );
00220     }
00221 }
00222 
00223 void MainWindow::slotAdjustColumns()
00224 {
00225     bool hidden = folderView->isHidden();
00226     if ( hidden ) folderView->show();
00227     folderView->setColumnWidth( 0, folderView->visibleWidth() );
00228     if ( hidden ) folderView->hide();
00229 
00230     mailView->setColumnWidth( 0, 10 );
00231     mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
00232     mailView->setColumnWidth( 2, 80 );
00233     mailView->setColumnWidth( 3, 50 );
00234     mailView->setColumnWidth( 4, 50 );
00235 }
00236 
00237 void MainWindow::slotEditSettings()
00238 {
00239 }
00240 
00241 void MainWindow::slotShowFolders( bool )
00242 {
00243    odebug << "slotShowFolders not reached" << oendl;
00244 }
00245 
00246 void MainWindow::refreshMailView(const QValueList<RecMailP>&)
00247 {
00248    odebug << "refreshMailView not reached" << oendl;
00249 }
00250 
00251 void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int )
00252 {
00253     odebug << "mailLeftClicked not reached" << oendl;
00254 }
00255 
00256 void MainWindow::displayMail()
00257 {
00258     odebug << "displayMail not reached" << oendl;
00259 }
00260 
00261 void MainWindow::slotDeleteMail()
00262 {
00263     odebug << "deleteMail not reached" << oendl;
00264 }
00265 
00266 void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int  )
00267 {
00268     odebug << "mailHold not reached" << oendl;
00269 }
00270 
00271 void MainWindow::slotSendQueued()
00272 {
00273 }
00274 
00275 void MainWindow::slotEditAccounts()
00276 {
00277 }
00278 
00279 void MainWindow::slotComposeMail()
00280 {
00281 }

Generated on Sat Nov 5 16:15:52 2005 for OPIE by  doxygen 1.4.2