author | alwin <alwin> | 2003-12-25 20:35:46 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-25 20:35:46 (UTC) |
commit | 34a7e0451c95e8a19735610553dba064b68823d9 (patch) (unidiff) | |
tree | d6f763a9571f65743ee45f9cee998fa74babe41a | |
parent | bde1302aed8a0e2506684eaae7c2d2d823de42c6 (diff) | |
download | opie-34a7e0451c95e8a19735610553dba064b68823d9.zip opie-34a7e0451c95e8a19735610553dba064b68823d9.tar.gz opie-34a7e0451c95e8a19735610553dba064b68823d9.tar.bz2 |
context menues for single mails when holding the stylus or left mouse button
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 43 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 8 |
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 | |||
@@ -114,20 +114,28 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
114 | statusWidget->hide(); | 114 | statusWidget->hide(); |
115 | 115 | ||
116 | layout->addWidget( mailView ); | 116 | layout->addWidget( mailView ); |
117 | layout->setStretchFactor( folderView, 1 ); | 117 | layout->setStretchFactor( folderView, 1 ); |
118 | layout->setStretchFactor( mailView, 2 ); | 118 | layout->setStretchFactor( mailView, 2 ); |
119 | 119 | ||
120 | 120 | ||
121 | slotAdjustLayout(); | 121 | slotAdjustLayout(); |
122 | 122 | ||
123 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 123 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
124 | SLOT( displayMail( QListViewItem * ) ) ); | 124 | |
125 | 125 | connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, | |
126 | SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); | ||
127 | |||
128 | connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | ||
129 | SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); | ||
130 | #if 0 | ||
131 | connect( mailView, SIGNAL( rightButtonClicked( QListViewItem *,const QPoint&,int ) ),this, | ||
132 | SLOT( mailHold(QListViewItem *,const QPoint&,int) )); | ||
133 | #endif | ||
126 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 134 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
127 | 135 | ||
128 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 136 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
129 | 137 | ||
130 | } | 138 | } |
131 | 139 | ||
132 | 140 | ||
133 | void MainWindow::slotAdjustLayout() { | 141 | void MainWindow::slotAdjustLayout() { |
@@ -178,23 +186,30 @@ void MainWindow::refreshMailView(QList<RecMail>*list) | |||
178 | MailListViewItem*item = 0; | 186 | MailListViewItem*item = 0; |
179 | mailView->clear(); | 187 | mailView->clear(); |
180 | for (unsigned int i = 0; i < list->count();++i) { | 188 | for (unsigned int i = 0; i < list->count();++i) { |
181 | item = new MailListViewItem(mailView,item); | 189 | item = new MailListViewItem(mailView,item); |
182 | item->storeData(*(list->at(i))); | 190 | item->storeData(*(list->at(i))); |
183 | item->showEntry(); | 191 | item->showEntry(); |
184 | } | 192 | } |
185 | } | 193 | } |
186 | void MainWindow::displayMail(QListViewItem*item) | 194 | void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) |
187 | { | 195 | { |
196 | /* just LEFT button - or tap with stylus on pda */ | ||
197 | if (button!=1) return; | ||
198 | if (!item) return; | ||
199 | displayMail(); | ||
200 | } | ||
188 | 201 | ||
202 | void MainWindow::displayMail() | ||
203 | { | ||
204 | QListViewItem*item = mailView->currentItem(); | ||
189 | if (!item) return; | 205 | if (!item) return; |
190 | RecMail mail = ((MailListViewItem*)item)->data(); | 206 | RecMail mail = ((MailListViewItem*)item)->data(); |
191 | RecBody body = folderView->fetchBody(mail); | 207 | RecBody body = folderView->fetchBody(mail); |
192 | |||
193 | ViewMail readMail( this ); | 208 | ViewMail readMail( this ); |
194 | readMail.setBody( body ); | 209 | readMail.setBody( body ); |
195 | readMail.setMail( mail ); | 210 | readMail.setMail( mail ); |
196 | readMail.showMaximized(); | 211 | readMail.showMaximized(); |
197 | readMail.exec(); | 212 | readMail.exec(); |
198 | 213 | ||
199 | if ( readMail.deleted ) { | 214 | if ( readMail.deleted ) { |
200 | folderView->refreshCurrent(); | 215 | folderView->refreshCurrent(); |
@@ -208,17 +223,31 @@ void MainWindow::slotDeleteMail() | |||
208 | if (!mailView->currentItem()) return; | 223 | if (!mailView->currentItem()) return; |
209 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 224 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
210 | 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 ) { | 225 | 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 ) { |
211 | mail.Wrapper()->deleteMail( mail ); | 226 | mail.Wrapper()->deleteMail( mail ); |
212 | folderView->refreshCurrent(); | 227 | folderView->refreshCurrent(); |
213 | } | 228 | } |
214 | } | 229 | } |
215 | 230 | ||
216 | 231 | void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int ) | |
232 | { | ||
233 | /* just the RIGHT button - or hold on pda */ | ||
234 | if (button!=2) {return;} | ||
235 | qDebug("Event right/hold"); | ||
236 | if (!item) return; | ||
237 | QPopupMenu *m = new QPopupMenu(0); | ||
238 | if (m) { | ||
239 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | ||
240 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | ||
241 | m->setFocus(); | ||
242 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | ||
243 | delete m; | ||
244 | } | ||
245 | } | ||
217 | 246 | ||
218 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 247 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
219 | :QListViewItem(parent,item),mail_data() | 248 | :QListViewItem(parent,item),mail_data() |
220 | { | 249 | { |
221 | } | 250 | } |
222 | 251 | ||
223 | void MailListViewItem::showEntry() | 252 | void MailListViewItem::showEntry() |
224 | { | 253 | { |
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 | |||
@@ -21,20 +21,22 @@ public: | |||
21 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 21 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
22 | 22 | ||
23 | public slots: | 23 | public slots: |
24 | void slotAdjustColumns(); | 24 | void slotAdjustColumns(); |
25 | 25 | ||
26 | protected slots: | 26 | protected slots: |
27 | virtual void slotShowFolders( bool show ); | 27 | virtual void slotShowFolders( bool show ); |
28 | virtual void refreshMailView(QList<RecMail>*); | 28 | virtual void refreshMailView(QList<RecMail>*); |
29 | virtual void displayMail(QListViewItem*); | 29 | virtual void displayMail(); |
30 | virtual void slotDeleteMail(); | 30 | virtual void slotDeleteMail(); |
31 | void slotAdjustLayout(); | 31 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
32 | void slotEditSettings(); | 32 | virtual void slotAdjustLayout(); |
33 | virtual void slotEditSettings(); | ||
34 | virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); | ||
33 | 35 | ||
34 | protected: | 36 | protected: |
35 | QToolBar *toolBar; | 37 | QToolBar *toolBar; |
36 | StatusWidget *statusWidget; | 38 | StatusWidget *statusWidget; |
37 | QMenuBar *menuBar; | 39 | QMenuBar *menuBar; |
38 | QPopupMenu *mailMenu, *settingsMenu; | 40 | QPopupMenu *mailMenu, *settingsMenu; |
39 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, | 41 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, |
40 | *editSettings, *editAccounts, *syncFolders; | 42 | *editSettings, *editAccounts, *syncFolders; |