summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-02 23:58:44 (UTC)
committer alwin <alwin>2004-01-02 23:58:44 (UTC)
commit86cac2c819dd683ac3f13be2c3bf1f28e0b83dab (patch) (unidiff)
tree3ee125def2a60097d19c22bbd155ef1353f68f85
parent9dbd01bcb23a56171d7ec24a9ca3fcd6f62bc6ab (diff)
downloadopie-86cac2c819dd683ac3f13be2c3bf1f28e0b83dab.zip
opie-86cac2c819dd683ac3f13be2c3bf1f28e0b83dab.tar.gz
opie-86cac2c819dd683ac3f13be2c3bf1f28e0b83dab.tar.bz2
settings dialog will show when clicked.
slots are all virtual so always the right one is called! Note: It is better to make all slots declared virtual - or do not make any child-classes!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp8
-rw-r--r--noncore/net/mail/mainwindow.h2
-rw-r--r--noncore/net/mail/opiemail.cpp6
-rw-r--r--noncore/net/mail/opiemail.h14
4 files changed, 14 insertions, 16 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index cf4cbe8..2a74286 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,303 +1,299 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qvbox.h> 2#include <qvbox.h>
3#include <qheader.h> 3#include <qheader.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qtextstream.h> 7#include <qtextstream.h>
8 8
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11 11
12#include "defines.h" 12#include "defines.h"
13#include "mainwindow.h" 13#include "mainwindow.h"
14#include "settingsdialog.h"
15#include "viewmail.h" 14#include "viewmail.h"
16#include "mailtypes.h" 15#include "mailtypes.h"
17#include "mailistviewitem.h" 16#include "mailistviewitem.h"
18 17
19 18
20MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 19MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
21 : QMainWindow( parent, name, flags ) 20 : QMainWindow( parent, name, flags )
22{ 21{
23 setCaption( tr( "Mail" ) ); 22 setCaption( tr( "Mail" ) );
24 setToolBarsMovable( false ); 23 setToolBarsMovable( false );
25 24
26 toolBar = new QToolBar( this ); 25 toolBar = new QToolBar( this );
27 menuBar = new QMenuBar( toolBar ); 26 menuBar = new QMenuBar( toolBar );
28 mailMenu = new QPopupMenu( menuBar ); 27 mailMenu = new QPopupMenu( menuBar );
29 menuBar->insertItem( tr( "Mail" ), mailMenu ); 28 menuBar->insertItem( tr( "Mail" ), mailMenu );
30 settingsMenu = new QPopupMenu( menuBar ); 29 settingsMenu = new QPopupMenu( menuBar );
31 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 30 menuBar->insertItem( tr( "Settings" ), settingsMenu );
32 31
33 addToolBar( toolBar ); 32 addToolBar( toolBar );
34 toolBar->setHorizontalStretchable( true ); 33 toolBar->setHorizontalStretchable( true );
35 34
36 QLabel *spacer = new QLabel( toolBar ); 35 QLabel *spacer = new QLabel( toolBar );
37 spacer->setBackgroundMode( QWidget::PaletteButton ); 36 spacer->setBackgroundMode( QWidget::PaletteButton );
38 toolBar->setStretchableWidget( spacer ); 37 toolBar->setStretchableWidget( spacer );
39 38
40 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 39 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
41 0, 0, this ); 40 0, 0, this );
42 composeMail->addTo( toolBar ); 41 composeMail->addTo( toolBar );
43 composeMail->addTo( mailMenu ); 42 composeMail->addTo( mailMenu );
44 43
45 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 44 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
46 0, 0, this ); 45 0, 0, this );
47 sendQueued->addTo( toolBar ); 46 sendQueued->addTo( toolBar );
48 sendQueued->addTo( mailMenu ); 47 sendQueued->addTo( mailMenu );
49 48
50 /* 49 /*
51 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 50 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
52 0, 0, this ); 51 0, 0, this );
53 syncFolders->addTo( toolBar ); 52 syncFolders->addTo( toolBar );
54 syncFolders->addTo( mailMenu ); 53 syncFolders->addTo( mailMenu );
55 */ 54 */
56 55
57 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 56 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
58 0, 0, this, 0, true ); 57 0, 0, this, 0, true );
59 showFolders->addTo( toolBar ); 58 showFolders->addTo( toolBar );
60 showFolders->addTo( mailMenu ); 59 showFolders->addTo( mailMenu );
61 showFolders->setOn( true ); 60 showFolders->setOn( true );
62 connect(showFolders, SIGNAL( toggled( bool ) ), 61 connect(showFolders, SIGNAL( toggled( bool ) ),
63 SLOT( slotShowFolders( bool ) ) ); 62 SLOT( slotShowFolders( bool ) ) );
64 63
65 /* 64 /*
66 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 65 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS,
67 0, 0, this ); 66 0, 0, this );
68 searchMails->addTo( toolBar ); 67 searchMails->addTo( toolBar );
69 searchMails->addTo( mailMenu ); 68 searchMails->addTo( mailMenu );
70 */ 69 */
71 70
72 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); 71 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
73 deleteMails->addTo( toolBar ); 72 deleteMails->addTo( toolBar );
74 deleteMails->addTo( mailMenu ); 73 deleteMails->addTo( mailMenu );
75 connect( deleteMails, SIGNAL( activated() ), 74 connect( deleteMails, SIGNAL( activated() ),
76 SLOT( slotDeleteMail() ) ); 75 SLOT( slotDeleteMail() ) );
77 76
78 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 77 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
79 0, 0, this ); 78 0, 0, this );
80 editSettings->addTo( settingsMenu ); 79 editSettings->addTo( settingsMenu );
81 connect( editSettings, SIGNAL( activated() ), 80 connect( editSettings, SIGNAL( activated() ),
82 SLOT( slotEditSettings() ) ); 81 SLOT( slotEditSettings() ) );
83
84 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 82 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
85 0, 0, this ); 83 0, 0, this );
86 editAccounts->addTo( settingsMenu ); 84 editAccounts->addTo( settingsMenu );
87 85
88 //setCentralWidget( view ); 86 //setCentralWidget( view );
89 87
90 QVBox* wrapperBox = new QVBox( this ); 88 QVBox* wrapperBox = new QVBox( this );
91 setCentralWidget( wrapperBox ); 89 setCentralWidget( wrapperBox );
92 90
93 QWidget *view = new QWidget( wrapperBox ); 91 QWidget *view = new QWidget( wrapperBox );
94 92
95 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 93 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
96 94
97 folderView = new AccountView( view ); 95 folderView = new AccountView( view );
98 folderView->header()->hide(); 96 folderView->header()->hide();
99 folderView->setRootIsDecorated( true ); 97 folderView->setRootIsDecorated( true );
100 folderView->addColumn( tr( "Mailbox" ) ); 98 folderView->addColumn( tr( "Mailbox" ) );
101 99
102 layout->addWidget( folderView ); 100 layout->addWidget( folderView );
103 101
104 mailView = new QListView( view ); 102 mailView = new QListView( view );
105 mailView->addColumn( tr( "" ) ); 103 mailView->addColumn( tr( "" ) );
106 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 104 mailView->addColumn( tr( "Subject" ),QListView::Manual );
107 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 105 mailView->addColumn( tr( "Sender" ),QListView::Manual );
108 mailView->addColumn( tr( "Size" ),QListView::Manual); 106 mailView->addColumn( tr( "Size" ),QListView::Manual);
109 mailView->addColumn( tr( "Date" )); 107 mailView->addColumn( tr( "Date" ));
110 mailView->setAllColumnsShowFocus(true); 108 mailView->setAllColumnsShowFocus(true);
111 mailView->setSorting(-1); 109 mailView->setSorting(-1);
112 110
113 statusWidget = new StatusWidget( wrapperBox ); 111 statusWidget = new StatusWidget( wrapperBox );
114 statusWidget->hide(); 112 statusWidget->hide();
115 113
116 layout->addWidget( mailView ); 114 layout->addWidget( mailView );
117 layout->setStretchFactor( folderView, 1 ); 115 layout->setStretchFactor( folderView, 1 );
118 layout->setStretchFactor( mailView, 2 ); 116 layout->setStretchFactor( mailView, 2 );
119 117
120 slotAdjustLayout(); 118 slotAdjustLayout();
121 119
122 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 120 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
123 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 121 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
124 122
125 connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, 123 connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this,
126 SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); 124 SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) );
127 connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 125 connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
128 SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); 126 SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) );
129 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 127 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
130 128
131 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 129 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
132} 130}
133 131
134 132
135void MainWindow::slotAdjustLayout() { 133void MainWindow::slotAdjustLayout() {
136 134
137 QWidget *d = QApplication::desktop(); 135 QWidget *d = QApplication::desktop();
138 136
139 if ( d->width() < d->height() ) { 137 if ( d->width() < d->height() ) {
140 layout->setDirection( QBoxLayout::TopToBottom ); 138 layout->setDirection( QBoxLayout::TopToBottom );
141 } else { 139 } else {
142 layout->setDirection( QBoxLayout::LeftToRight ); 140 layout->setDirection( QBoxLayout::LeftToRight );
143 } 141 }
144} 142}
145 143
146void MainWindow::slotAdjustColumns() 144void MainWindow::slotAdjustColumns()
147{ 145{
148 bool hidden = folderView->isHidden(); 146 bool hidden = folderView->isHidden();
149 if ( hidden ) folderView->show(); 147 if ( hidden ) folderView->show();
150 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 148 folderView->setColumnWidth( 0, folderView->visibleWidth() );
151 if ( hidden ) folderView->hide(); 149 if ( hidden ) folderView->hide();
152 150
153 mailView->setColumnWidth( 0, 10 ); 151 mailView->setColumnWidth( 0, 10 );
154 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 152 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
155 mailView->setColumnWidth( 2, 80 ); 153 mailView->setColumnWidth( 2, 80 );
156 mailView->setColumnWidth( 3, 50 ); 154 mailView->setColumnWidth( 3, 50 );
157 mailView->setColumnWidth( 4, 50 ); 155 mailView->setColumnWidth( 4, 50 );
158} 156}
159 157
160void MainWindow::slotEditSettings() { 158void MainWindow::slotEditSettings()
161 SettingsDialog settingsDialog( this, 0, true ); 159{
162 settingsDialog.showMaximized();
163 settingsDialog.exec();
164} 160}
165 161
166void MainWindow::slotShowFolders( bool show ) 162void MainWindow::slotShowFolders( bool show )
167{ 163{
168 qDebug( "Show Folders" ); 164 qDebug( "Show Folders" );
169 if ( show && folderView->isHidden() ) { 165 if ( show && folderView->isHidden() ) {
170 qDebug( "-> showing" ); 166 qDebug( "-> showing" );
171 folderView->show(); 167 folderView->show();
172 } else if ( !show && !folderView->isHidden() ) { 168 } else if ( !show && !folderView->isHidden() ) {
173 qDebug( "-> hiding" ); 169 qDebug( "-> hiding" );
174 folderView->hide(); 170 folderView->hide();
175 } 171 }
176} 172}
177 173
178void MainWindow::refreshMailView(QList<RecMail>*list) 174void MainWindow::refreshMailView(QList<RecMail>*list)
179{ 175{
180 MailListViewItem*item = 0; 176 MailListViewItem*item = 0;
181 mailView->clear(); 177 mailView->clear();
182 for (unsigned int i = 0; i < list->count();++i) { 178 for (unsigned int i = 0; i < list->count();++i) {
183 item = new MailListViewItem(mailView,item); 179 item = new MailListViewItem(mailView,item);
184 item->storeData(*(list->at(i))); 180 item->storeData(*(list->at(i)));
185 item->showEntry(); 181 item->showEntry();
186 } 182 }
187} 183}
188void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) 184void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
189{ 185{
190 /* just LEFT button - or tap with stylus on pda */ 186 /* just LEFT button - or tap with stylus on pda */
191 if (button!=1) return; 187 if (button!=1) return;
192 if (!item) return; 188 if (!item) return;
193 displayMail(); 189 displayMail();
194} 190}
195 191
196void MainWindow::displayMail() 192void MainWindow::displayMail()
197{ 193{
198 QListViewItem*item = mailView->currentItem(); 194 QListViewItem*item = mailView->currentItem();
199 if (!item) return; 195 if (!item) return;
200 RecMail mail = ((MailListViewItem*)item)->data(); 196 RecMail mail = ((MailListViewItem*)item)->data();
201 RecBody body = folderView->fetchBody(mail); 197 RecBody body = folderView->fetchBody(mail);
202 ViewMail readMail( this ); 198 ViewMail readMail( this );
203 readMail.setBody( body ); 199 readMail.setBody( body );
204 readMail.setMail( mail ); 200 readMail.setMail( mail );
205 readMail.showMaximized(); 201 readMail.showMaximized();
206 readMail.exec(); 202 readMail.exec();
207 203
208 if ( readMail.deleted ) { 204 if ( readMail.deleted ) {
209 folderView->refreshCurrent(); 205 folderView->refreshCurrent();
210 } else { 206 } else {
211 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); 207 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") );
212 } 208 }
213} 209}
214 210
215void MainWindow::slotDeleteMail() 211void MainWindow::slotDeleteMail()
216{ 212{
217 if (!mailView->currentItem()) return; 213 if (!mailView->currentItem()) return;
218 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 214 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
219 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 ) { 215 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 ) {
220 mail.Wrapper()->deleteMail( mail ); 216 mail.Wrapper()->deleteMail( mail );
221 folderView->refreshCurrent(); 217 folderView->refreshCurrent();
222 } 218 }
223} 219}
224 220
225void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int ) 221void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int )
226{ 222{
227 /* just the RIGHT button - or hold on pda */ 223 /* just the RIGHT button - or hold on pda */
228 if (button!=2) {return;} 224 if (button!=2) {return;}
229 qDebug("Event right/hold"); 225 qDebug("Event right/hold");
230 if (!item) return; 226 if (!item) return;
231 QPopupMenu *m = new QPopupMenu(0); 227 QPopupMenu *m = new QPopupMenu(0);
232 if (m) { 228 if (m) {
233 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 229 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
234 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 230 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
235 m->setFocus(); 231 m->setFocus();
236 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 232 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
237 delete m; 233 delete m;
238 } 234 }
239} 235}
240 236
241MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 237MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
242 :QListViewItem(parent,item),mail_data() 238 :QListViewItem(parent,item),mail_data()
243{ 239{
244} 240}
245 241
246void MailListViewItem::showEntry() 242void MailListViewItem::showEntry()
247{ 243{
248 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { 244 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
249 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); 245 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
250 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 246 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
251 /* I think it looks nicer if there are not such a log of icons but only on mails 247 /* I think it looks nicer if there are not such a log of icons but only on mails
252 replied or new - Alwin*/ 248 replied or new - Alwin*/
253 //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); 249 //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
254 } else { 250 } else {
255 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); 251 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
256 } 252 }
257 double s = mail_data.Msgsize(); 253 double s = mail_data.Msgsize();
258 int w; 254 int w;
259 w=0; 255 w=0;
260 256
261 while (s>1024) { 257 while (s>1024) {
262 s/=1024; 258 s/=1024;
263 ++w; 259 ++w;
264 if (w>=2) break; 260 if (w>=2) break;
265 } 261 }
266 262
267 QString q=""; 263 QString q="";
268 QString fsize=""; 264 QString fsize="";
269 switch(w) { 265 switch(w) {
270 case 1: 266 case 1:
271 q="k"; 267 q="k";
272 break; 268 break;
273 case 2: 269 case 2:
274 q="M"; 270 q="M";
275 break; 271 break;
276 default: 272 default:
277 break; 273 break;
278 } 274 }
279 275
280 { 276 {
281 QTextOStream o(&fsize); 277 QTextOStream o(&fsize);
282 if (w>0) o.precision(2); else o.precision(0); 278 if (w>0) o.precision(2); else o.precision(0);
283 o.setf(QTextStream::fixed); 279 o.setf(QTextStream::fixed);
284 o << s << " " << q << "Byte"; 280 o << s << " " << q << "Byte";
285 } 281 }
286 282
287 setText(1,mail_data.getSubject()); 283 setText(1,mail_data.getSubject());
288 setText(2,mail_data.getFrom()); 284 setText(2,mail_data.getFrom());
289 setText(3,fsize); 285 setText(3,fsize);
290 setText(4,mail_data.getDate()); 286 setText(4,mail_data.getDate());
291} 287}
292 288
293void MailListViewItem::storeData(const RecMail&data) 289void MailListViewItem::storeData(const RecMail&data)
294{ 290{
295 mail_data = data; 291 mail_data = data;
296} 292}
297 293
298const RecMail& MailListViewItem::data()const 294const RecMail& MailListViewItem::data()const
299{ 295{
300 return mail_data; 296 return mail_data;
301} 297}
302 298
303 299
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 638232a..0e077f6 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -1,48 +1,48 @@
1#ifndef MAINWINDOW_H 1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H 2#define MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlistview.h> 5#include <qlistview.h>
6#include <qaction.h> 6#include <qaction.h>
7 7
8#include <qtoolbar.h> 8#include <qtoolbar.h>
9#include <qmenubar.h> 9#include <qmenubar.h>
10 10
11#include "accountview.h" 11#include "accountview.h"
12#include "statuswidget.h" 12#include "statuswidget.h"
13 13
14class RecMail; 14class RecMail;
15 15
16class MainWindow : public QMainWindow 16class MainWindow : public QMainWindow
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19 19
20public: 20public:
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
23public slots: 23public slots:
24 void slotAdjustColumns(); 24 virtual void slotAdjustColumns();
25 25
26protected slots: 26protected 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(); 29 virtual void displayMail();
30 virtual void slotDeleteMail(); 30 virtual void slotDeleteMail();
31 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 31 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
32 virtual void slotAdjustLayout(); 32 virtual void slotAdjustLayout();
33 virtual void slotEditSettings(); 33 virtual void slotEditSettings();
34 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); 34 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
35 35
36protected: 36protected:
37 QToolBar *toolBar; 37 QToolBar *toolBar;
38 StatusWidget *statusWidget; 38 StatusWidget *statusWidget;
39 QMenuBar *menuBar; 39 QMenuBar *menuBar;
40 QPopupMenu *mailMenu, *settingsMenu; 40 QPopupMenu *mailMenu, *settingsMenu;
41 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, 41 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
42 *editSettings, *editAccounts, *syncFolders; 42 *editSettings, *editAccounts, *syncFolders;
43 AccountView *folderView; 43 AccountView *folderView;
44 QListView *mailView; 44 QListView *mailView;
45 QBoxLayout *layout; 45 QBoxLayout *layout;
46}; 46};
47 47
48#endif 48#endif
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 2909893..e35f5b6 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,110 +1,112 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2#include "settingsdialog.h"
2#include "opiemail.h" 3#include "opiemail.h"
3#include "editaccounts.h" 4#include "editaccounts.h"
4#include "composemail.h" 5#include "composemail.h"
5#include "smtpwrapper.h" 6#include "smtpwrapper.h"
6#include <qpe/qcopenvelope_qws.h> 7#include <qpe/qcopenvelope_qws.h>
7#include <qaction.h> 8#include <qaction.h>
8#include <qapplication.h> 9#include <qapplication.h>
9 10
10OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 11OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
11 : MainWindow( parent, name, flags ) 12 : MainWindow( parent, name, flags )
12{ 13{
13 settings = new Settings(); 14 settings = new Settings();
14 15
15 folderView->populate( settings->getAccounts() ); 16 folderView->populate( settings->getAccounts() );
16 17
17 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 18 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
18 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 19 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
19// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 20// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
20 connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) );
21 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 21 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
22 // Added by Stefan Eilers to allow starting by addressbook.. 22 // Added by Stefan Eilers to allow starting by addressbook..
23 // copied from old mail2 23 // copied from old mail2
24#if !defined(QT_NO_COP) 24#if !defined(QT_NO_COP)
25 connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), 25 connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ),
26 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 26 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
27#endif 27#endif
28} 28}
29 29
30void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 30void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
31{ 31{
32 // copied from old mail2 32 // copied from old mail2
33 if (msg == "writeMail(QString,QString)") { 33 if (msg == "writeMail(QString,QString)") {
34 QDataStream stream(data,IO_ReadOnly); 34 QDataStream stream(data,IO_ReadOnly);
35 QString name, email; 35 QString name, email;
36 stream >> name >> email; 36 stream >> name >> email;
37 // removing the whitespaces at beginning and end is needed! 37 // removing the whitespaces at beginning and end is needed!
38 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 38 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
39 } else if (msg == "newMail()") { 39 } else if (msg == "newMail()") {
40 slotComposeMail(); 40 slotComposeMail();
41 } 41 }
42} 42}
43 43
44void OpieMail::slotwriteMail(const QString&name,const QString&email) 44void OpieMail::slotwriteMail(const QString&name,const QString&email)
45{ 45{
46 ComposeMail compose( settings, this, 0 , true ); 46 ComposeMail compose( settings, this, 0 , true );
47 if (!email.isEmpty()) { 47 if (!email.isEmpty()) {
48 if (!name.isEmpty()) { 48 if (!name.isEmpty()) {
49 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 49 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
50 } else { 50 } else {
51 compose.setTo(email); 51 compose.setTo(email);
52 } 52 }
53 } 53 }
54 compose.showMaximized(); 54 compose.showMaximized();
55 compose.slotAdjustColumns(); 55 compose.slotAdjustColumns();
56 compose.exec(); 56 compose.exec();
57} 57}
58 58
59void OpieMail::slotComposeMail() 59void OpieMail::slotComposeMail()
60{ 60{
61 qDebug( "Compose Mail" ); 61 qDebug( "Compose Mail" );
62 slotwriteMail(0l,0l); 62 slotwriteMail(0l,0l);
63} 63}
64 64
65void OpieMail::slotSendQueued() 65void OpieMail::slotSendQueued()
66{ 66{
67 qDebug( "Send Queued" ); 67 qDebug( "Send Queued" );
68 SMTPaccount *smtp = 0; 68 SMTPaccount *smtp = 0;
69 69
70 QList<Account> list = settings->getAccounts(); 70 QList<Account> list = settings->getAccounts();
71 Account *it; 71 Account *it;
72// if (list.count()==1) { 72// if (list.count()==1) {
73 for ( it = list.first(); it; it = list.next() ) { 73 for ( it = list.first(); it; it = list.next() ) {
74 if ( it->getType().compare( "SMTP" ) == 0 ) { 74 if ( it->getType().compare( "SMTP" ) == 0 ) {
75 smtp = static_cast<SMTPaccount *>(it); 75 smtp = static_cast<SMTPaccount *>(it);
76 break; 76 break;
77 } 77 }
78 } 78 }
79// } 79// }
80 if (smtp) { 80 if (smtp) {
81 SMTPwrapper * wrap = new SMTPwrapper(settings); 81 SMTPwrapper * wrap = new SMTPwrapper(settings);
82 if ( wrap->flushOutbox(smtp) ) { 82 if ( wrap->flushOutbox(smtp) ) {
83 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 83 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
84 } 84 }
85 } 85 }
86} 86}
87 87
88void OpieMail::slotSearchMails() 88void OpieMail::slotSearchMails()
89{ 89{
90 qDebug( "Search Mails" ); 90 qDebug( "Search Mails" );
91} 91}
92 92
93void OpieMail::slotEditSettings() 93void OpieMail::slotEditSettings()
94{ 94{
95 qDebug( "Edit Settings" ); 95 SettingsDialog settingsDialog( this, 0, true );
96 settingsDialog.showMaximized();
97 settingsDialog.exec();
96} 98}
97 99
98void OpieMail::slotEditAccounts() 100void OpieMail::slotEditAccounts()
99{ 101{
100 qDebug( "Edit Accounts" ); 102 qDebug( "Edit Accounts" );
101 EditAccounts eaDialog( settings, this, 0, true ); 103 EditAccounts eaDialog( settings, this, 0, true );
102 eaDialog.showMaximized(); 104 eaDialog.showMaximized();
103 eaDialog.slotAdjustColumns(); 105 eaDialog.slotAdjustColumns();
104 eaDialog.exec(); 106 eaDialog.exec();
105 if ( settings ) delete settings; 107 if ( settings ) delete settings;
106 settings = new Settings(); 108 settings = new Settings();
107 109
108 folderView->populate( settings->getAccounts() ); 110 folderView->populate( settings->getAccounts() );
109} 111}
110 112
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index 8cbcaa4..4e3c974 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -1,29 +1,29 @@
1#ifndef OPIEMAIL_H 1#ifndef OPIEMAIL_H
2#define OPIEMAIL_H 2#define OPIEMAIL_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include "settings.h" 5#include "settings.h"
6 6
7class OpieMail : public MainWindow 7class OpieMail : public MainWindow
8{ 8{
9 Q_OBJECT 9 Q_OBJECT
10 10
11public: 11public:
12 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 12 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
13 static QString appName() { return QString::fromLatin1("opiemail"); } 13 static QString appName() { return QString::fromLatin1("opiemail"); }
14 14
15public slots: 15public slots:
16 void slotwriteMail(const QString&name,const QString&email); 16 virtual void slotwriteMail(const QString&name,const QString&email);
17 void slotComposeMail(); 17 virtual void slotComposeMail();
18 void appMessage(const QCString &msg, const QByteArray &data); 18 virtual void appMessage(const QCString &msg, const QByteArray &data);
19protected slots: 19protected slots:
20 void slotSendQueued(); 20 virtual void slotSendQueued();
21 void slotSearchMails(); 21 virtual void slotSearchMails();
22 void slotEditSettings(); 22 virtual void slotEditSettings();
23 void slotEditAccounts(); 23 virtual void slotEditAccounts();
24private: 24private:
25 Settings *settings; 25 Settings *settings;
26 26
27}; 27};
28 28
29#endif 29#endif