From e3b89230f065c48c84b48c88edb6eb088374c487 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 03 Jul 2004 16:33:12 +0000 Subject: Initial revision --- (limited to 'kmicromail/mainwindow.cpp') diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp new file mode 100644 index 0000000..78377ea --- a/dev/null +++ b/kmicromail/mainwindow.cpp @@ -0,0 +1,232 @@ +#include +#include +#include +#include +#include +#include +#include + +#ifndef DESKTOP_VERSION +#include +#endif +#include "defines.h" +#include "mainwindow.h" +#include + + +#include + +MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) + : QMainWindow( parent, name, flags ) +{ + setCaption( tr( "KMicroMail" ) ); + setToolBarsMovable( false ); + KABC::StdAddressBook::self(); + 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" ), SmallIcon("composemail"), + 0, 0, this ); + composeMail->addTo( toolBar ); + composeMail->addTo( mailMenu ); + + sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("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" ), SmallIcon("showfolders") , + 0, 0, this, 0, true ); + showFolders->addTo( toolBar ); + showFolders->addTo( mailMenu ); + showFolders->setOn( true ); + connect(showFolders, SIGNAL( toggled(bool) ), + SLOT( slotShowFolders(bool) ) ); + + /* + searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ), + 0, 0, this ); + searchMails->addTo( toolBar ); + searchMails->addTo( mailMenu ); + */ + + deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this); + deleteMails->addTo( toolBar ); + deleteMails->addTo( mailMenu ); + connect( deleteMails, SIGNAL( activated() ), + SLOT( slotDeleteMail() ) ); + + editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") , + 0, 0, this ); + editSettings->addTo( settingsMenu ); + connect( editSettings, SIGNAL( activated() ), + SLOT( slotEditSettings() ) ); + editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") , + 0, 0, this ); + editAccounts->addTo( settingsMenu ); + + //setCentralWidget( view ); + + QVBox* wrapperBox = new QVBox( this ); + setCentralWidget( wrapperBox ); + + // QWidget *view = new QWidget( wrapperBox ); + KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); + split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); + //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); + + folderView = new AccountView( split ); + folderView->header()->hide(); + folderView->setRootIsDecorated( true ); + folderView->addColumn( tr( "Mailbox" ) ); + + //layout->addWidget( folderView ); + + mailView = new QListView( split ); + mailView->addColumn( tr( "" ) ); + mailView->addColumn( tr( "Subject" ),QListView::Manual ); + mailView->addColumn( tr( "Sender" ),QListView::Manual ); + mailView->addColumn( tr( "Size" ),QListView::Manual); + mailView->addColumn( tr( "Date" )); + mailView->setAllColumnsShowFocus(true); + //mailView->setSorting(-1); + + statusWidget = new StatusWidget( wrapperBox ); + statusWidget->hide(); + + //layout->addWidget( mailView ); + //layout->setStretchFactor( folderView, 1 ); + //layout->setStretchFactor( mailView, 2 ); + + slotAdjustLayout(); +#ifndef DESKTOP_VERSION + QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); + QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); +#endif + connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, + SLOT( mailLeftClicked(QListViewItem*) ) ); + connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, + SLOT( mailLeftClicked(QListViewItem*) ) ); + connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, + SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); + connect(folderView, SIGNAL(refreshMailview(const QValueList&)), + this,SLOT(refreshMailView(const QValueList&))); + connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); + connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); +// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); + connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); + mailView->setMultiSelection ( true ); + //mailView->setSelectionMode( QListView::Extended ); + QValueList list; + int fw = 100; + if ( QApplication::desktop()->width() > 320 ) + fw = 50; + list.append( fw ); + list.append( 100 ); + split->setSizes( list ); + QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); + mailView->setShowSortIndicator ( true ); +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::appMessage(const QCString &, const QByteArray &) +{ + qDebug("appMessage implemented by subclass"); +} + +void MainWindow::slotAdjustLayout() { + + /* + QWidget *d = QApplication::desktop(); + + if ( d->width() < d->height() ) { + layout->setDirection( QBoxLayout::TopToBottom ); + } else { + 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 ); + mailView->setColumnWidth( 3, 50 ); + mailView->setColumnWidth( 4, 50 ); +} + +void MainWindow::slotEditSettings() +{ +} + +void MainWindow::slotShowFolders( bool ) +{ + qDebug("not implemented: "); +} + +void MainWindow::refreshMailView(const QValueList&) +{ + qDebug("not implemented: "); +} + +void MainWindow::mailLeftClicked(QListViewItem * ) +{ + qDebug("not implemented: "); +} + +void MainWindow::displayMail() +{ + qDebug("not implemented: "); +} + +void MainWindow::slotDeleteMail() +{ + qDebug("not implemented: "); +} + +void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) +{ + qDebug("not implemented: "); +} + +void MainWindow::slotSendQueued() +{ + qDebug("not implemented: "); +} + +void MainWindow::slotEditAccounts() +{ + qDebug("not implemented: "); +} + +void MainWindow::slotComposeMail() +{ + qDebug("not implemented: "); +} -- cgit v0.9.0.2