summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp43
-rw-r--r--noncore/net/mail/mainwindow.h8
2 files changed, 41 insertions, 10 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index a57fb0d..dc8c188 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -98,52 +98,60 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
folderView->header()->hide();
folderView->setRootIsDecorated( true );
folderView->addColumn( tr( "Mailbox" ) );
layout->addWidget( folderView );
mailView = new QListView( view );
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();
-
- connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
- SLOT( displayMail( QListViewItem * ) ) );
-
+
+ QPEApplication::setStylusOperation( mailView->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 ) ) );
+#if 0
+ connect( mailView, SIGNAL( rightButtonClicked( QListViewItem *,const QPoint&,int ) ),this,
+ SLOT( mailHold(QListViewItem *,const QPoint&,int) ));
+#endif
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 );
}
}
void MainWindow::slotAdjustColumns()
{
bool hidden = folderView->isHidden();
if ( hidden ) folderView->show();
folderView->setColumnWidth( 0, folderView->visibleWidth() );
if ( hidden ) folderView->hide();
@@ -162,79 +170,100 @@ void MainWindow::slotEditSettings() {
}
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)
+void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
{
+ /* just LEFT button - or tap with stylus on pda */
+ if (button!=1) return;
+ if (!item) return;
+ displayMail();
+}
+void MainWindow::displayMail()
+{
+ QListViewItem*item = mailView->currentItem();
if (!item) return;
RecMail mail = ((MailListViewItem*)item)->data();
RecBody body = folderView->fetchBody(mail);
-
ViewMail readMail( this );
readMail.setBody( body );
readMail.setMail( mail );
readMail.showMaximized();
readMail.exec();
if ( readMail.deleted ) {
folderView->refreshCurrent();
} else {
( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") );
}
}
void MainWindow::slotDeleteMail()
{
if (!mailView->currentItem()) return;
RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
mail.Wrapper()->deleteMail( mail );
folderView->refreshCurrent();
}
}
-
+void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int )
+{
+ /* just the RIGHT button - or hold on pda */
+ if (button!=2) {return;}
+ qDebug("Event right/hold");
+ if (!item) return;
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
+ m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
+ m->setFocus();
+ m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
+ delete m;
+ }
+}
MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
:QListViewItem(parent,item),mail_data()
{
}
void MailListViewItem::showEntry()
{
if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
} else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
/* I think it looks nicer if there are not such a log of icons but only on mails
replied or new - Alwin*/
//setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
} else {
setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
}
double s = mail_data.Msgsize();
int w;
w=0;
while (s>1024) {
s/=1024;
++w;
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 4e4f4bb..638232a 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -5,42 +5,44 @@
#include <qlistview.h>
#include <qaction.h>
#include <qtoolbar.h>
#include <qmenubar.h>
#include "accountview.h"
#include "statuswidget.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*);
+ virtual void displayMail();
virtual void slotDeleteMail();
- void slotAdjustLayout();
- void slotEditSettings();
+ 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;
};
#endif