summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-12-14 02:24:35 (UTC)
committer harlekin <harlekin>2003-12-14 02:24:35 (UTC)
commit12ba6ab9606538628afc7f7015e115a0251d0389 (patch) (unidiff)
treea7c9da2ecd69320cf90a0db19399815e4aff5d12
parent568f23df5f4d5b1835c3b89ad54eeb6fc53157e6 (diff)
downloadopie-12ba6ab9606538628afc7f7015e115a0251d0389.zip
opie-12ba6ab9606538628afc7f7015e115a0251d0389.tar.gz
opie-12ba6ab9606538628afc7f7015e115a0251d0389.tar.bz2
show account list by default
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index e466d9b..cab1a66 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,220 +1,222 @@
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 7
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/resource.h> 9#include <qpe/resource.h>
10 10
11#include "defines.h" 11#include "defines.h"
12#include "mainwindow.h" 12#include "mainwindow.h"
13#include "viewmail.h" 13#include "viewmail.h"
14#include "mailtypes.h" 14#include "mailtypes.h"
15#include "mailistviewitem.h" 15#include "mailistviewitem.h"
16 16
17MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 17MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
18 : QMainWindow( parent, name, flags ) 18 : QMainWindow( parent, name, flags )
19{ 19{
20 setCaption( tr( "Mail" ) ); 20 setCaption( tr( "Mail" ) );
21 setToolBarsMovable( false ); 21 setToolBarsMovable( false );
22 22
23 toolBar = new QToolBar( this ); 23 toolBar = new QToolBar( this );
24 menuBar = new QMenuBar( toolBar ); 24 menuBar = new QMenuBar( toolBar );
25 mailMenu = new QPopupMenu( menuBar ); 25 mailMenu = new QPopupMenu( menuBar );
26 menuBar->insertItem( tr( "Mail" ), mailMenu ); 26 menuBar->insertItem( tr( "Mail" ), mailMenu );
27 settingsMenu = new QPopupMenu( menuBar ); 27 settingsMenu = new QPopupMenu( menuBar );
28 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 28 menuBar->insertItem( tr( "Settings" ), settingsMenu );
29 29
30 addToolBar( toolBar ); 30 addToolBar( toolBar );
31 toolBar->setHorizontalStretchable( true ); 31 toolBar->setHorizontalStretchable( true );
32 32
33 QLabel *spacer = new QLabel( toolBar ); 33 QLabel *spacer = new QLabel( toolBar );
34 spacer->setBackgroundMode( QWidget::PaletteButton ); 34 spacer->setBackgroundMode( QWidget::PaletteButton );
35 toolBar->setStretchableWidget( spacer ); 35 toolBar->setStretchableWidget( spacer );
36 36
37 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 37 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
38 0, 0, this ); 38 0, 0, this );
39 composeMail->addTo( toolBar ); 39 composeMail->addTo( toolBar );
40 composeMail->addTo( mailMenu ); 40 composeMail->addTo( mailMenu );
41 41
42 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 42 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
43 0, 0, this ); 43 0, 0, this );
44 sendQueued->addTo( toolBar ); 44 sendQueued->addTo( toolBar );
45 sendQueued->addTo( mailMenu ); 45 sendQueued->addTo( mailMenu );
46 46
47 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 47 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
48 0, 0, this ); 48 0, 0, this );
49 syncFolders->addTo( toolBar ); 49 syncFolders->addTo( toolBar );
50 syncFolders->addTo( mailMenu ); 50 syncFolders->addTo( mailMenu );
51 51
52 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 52 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
53 0, 0, this, 0, true ); 53 0, 0, this, 0, true );
54 showFolders->addTo( toolBar ); 54 showFolders->addTo( toolBar );
55 showFolders->addTo( mailMenu ); 55 showFolders->addTo( mailMenu );
56 showFolders->setOn( true );
56 connect(showFolders, SIGNAL( toggled( bool ) ), 57 connect(showFolders, SIGNAL( toggled( bool ) ),
57 SLOT( slotShowFolders( bool ) ) ); 58 SLOT( slotShowFolders( bool ) ) );
58 59
59 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 60 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS,
60 0, 0, this ); 61 0, 0, this );
61 searchMails->addTo( toolBar ); 62 searchMails->addTo( toolBar );
62 searchMails->addTo( mailMenu ); 63 searchMails->addTo( mailMenu );
63 64
64 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); 65 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
65 deleteMails->addTo( toolBar ); 66 deleteMails->addTo( toolBar );
66 deleteMails->addTo( mailMenu ); 67 deleteMails->addTo( mailMenu );
67 connect( deleteMails, SIGNAL( activated() ), 68 connect( deleteMails, SIGNAL( activated() ),
68 SLOT( slotDeleteMail() ) ); 69 SLOT( slotDeleteMail() ) );
69 70
70 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 71 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
71 0, 0, this ); 72 0, 0, this );
72 editSettings->addTo( settingsMenu ); 73 editSettings->addTo( settingsMenu );
73 74
74 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 75 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
75 0, 0, this ); 76 0, 0, this );
76 editAccounts->addTo( settingsMenu ); 77 editAccounts->addTo( settingsMenu );
77 78
78 QWidget *view = new QWidget( this ); 79 QWidget *view = new QWidget( this );
79 setCentralWidget( view ); 80 setCentralWidget( view );
80 81
81 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 82 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
82 83
83 folderView = new AccountView( view ); 84 folderView = new AccountView( view );
84 folderView->header()->hide(); 85 folderView->header()->hide();
85 folderView->setRootIsDecorated( false ); 86 folderView->setRootIsDecorated( false );
86 folderView->addColumn( tr( "Mailbox" ) ); 87 folderView->addColumn( tr( "Mailbox" ) );
87 folderView->hide(); 88 //folderView->hide();
88 89
89 layout->addWidget( folderView ); 90 layout->addWidget( folderView );
90 91
91 mailView = new QListView( view ); 92 mailView = new QListView( view );
92 mailView->addColumn( tr( "" ) ); 93 mailView->addColumn( tr( "" ) );
93 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 94 mailView->addColumn( tr( "Subject" ),QListView::Manual );
94 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 95 mailView->addColumn( tr( "Sender" ),QListView::Manual );
95 mailView->addColumn( tr( "Date" )); 96 mailView->addColumn( tr( "Date" ));
96 mailView->setAllColumnsShowFocus(true); 97 mailView->setAllColumnsShowFocus(true);
97 mailView->setSorting(-1); 98 mailView->setSorting(-1);
98 99
99 layout->addWidget( mailView ); 100 layout->addWidget( mailView );
100 layout->setStretchFactor( folderView, 1 ); 101 layout->setStretchFactor( folderView, 1 );
101 layout->setStretchFactor( mailView, 2 ); 102 layout->setStretchFactor( mailView, 2 );
102 103
103 slotAdjustLayout(); 104 slotAdjustLayout();
104 105
105 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, 106 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
106 SLOT( displayMail( QListViewItem * ) ) ); 107 SLOT( displayMail( QListViewItem * ) ) );
107 108
108 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 109 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
109 110
110 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 111 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
112
111} 113}
112 114
113 115
114void MainWindow::slotAdjustLayout() { 116void MainWindow::slotAdjustLayout() {
115 117
116 QWidget *d = QApplication::desktop(); 118 QWidget *d = QApplication::desktop();
117 119
118 if ( d->width() < d->height() ) { 120 if ( d->width() < d->height() ) {
119 layout->setDirection( QBoxLayout::TopToBottom ); 121 layout->setDirection( QBoxLayout::TopToBottom );
120 } else { 122 } else {
121 layout->setDirection( QBoxLayout::LeftToRight ); 123 layout->setDirection( QBoxLayout::LeftToRight );
122 } 124 }
123 delete d; 125 delete d;
124} 126}
125 127
126void MainWindow::slotAdjustColumns() 128void MainWindow::slotAdjustColumns()
127{ 129{
128 bool hidden = folderView->isHidden(); 130 bool hidden = folderView->isHidden();
129 if ( hidden ) folderView->show(); 131 if ( hidden ) folderView->show();
130 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 132 folderView->setColumnWidth( 0, folderView->visibleWidth() );
131 if ( hidden ) folderView->hide(); 133 if ( hidden ) folderView->hide();
132 134
133 mailView->setColumnWidth( 0, 10 ); 135 mailView->setColumnWidth( 0, 10 );
134 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 136 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
135 mailView->setColumnWidth( 2, 80 ); 137 mailView->setColumnWidth( 2, 80 );
136 mailView->setColumnWidth( 3, 50 ); 138 mailView->setColumnWidth( 3, 50 );
137} 139}
138 140
139void MainWindow::slotShowFolders( bool show ) 141void MainWindow::slotShowFolders( bool show )
140{ 142{
141 qDebug( "Show Folders" ); 143 qDebug( "Show Folders" );
142 if ( show && folderView->isHidden() ) { 144 if ( show && folderView->isHidden() ) {
143 qDebug( "-> showing" ); 145 qDebug( "-> showing" );
144 folderView->show(); 146 folderView->show();
145 } else if ( !show && !folderView->isHidden() ) { 147 } else if ( !show && !folderView->isHidden() ) {
146 qDebug( "-> hiding" ); 148 qDebug( "-> hiding" );
147 folderView->hide(); 149 folderView->hide();
148 } 150 }
149} 151}
150 152
151void MainWindow::refreshMailView(QList<RecMail>*list) 153void MainWindow::refreshMailView(QList<RecMail>*list)
152{ 154{
153 MailListViewItem*item = 0; 155 MailListViewItem*item = 0;
154 mailView->clear(); 156 mailView->clear();
155 for (unsigned int i = 0; i < list->count();++i) { 157 for (unsigned int i = 0; i < list->count();++i) {
156 item = new MailListViewItem(mailView,item); 158 item = new MailListViewItem(mailView,item);
157 item->storeData(*(list->at(i))); 159 item->storeData(*(list->at(i)));
158 item->showEntry(); 160 item->showEntry();
159 } 161 }
160} 162}
161void MainWindow::displayMail(QListViewItem*item) 163void MainWindow::displayMail(QListViewItem*item)
162{ 164{
163 165
164 if (!item) return; 166 if (!item) return;
165 RecMail mail = ((MailListViewItem*)item)->data(); 167 RecMail mail = ((MailListViewItem*)item)->data();
166 RecBody body = folderView->fetchBody(mail); 168 RecBody body = folderView->fetchBody(mail);
167 169
168 ViewMail readMail( this ); 170 ViewMail readMail( this );
169 readMail.setBody( body ); 171 readMail.setBody( body );
170 readMail.setMail( mail ); 172 readMail.setMail( mail );
171 readMail.showMaximized(); 173 readMail.showMaximized();
172 readMail.exec(); 174 readMail.exec();
173 175
174 if ( readMail.deleted ) { 176 if ( readMail.deleted ) {
175 folderView->refreshCurrent(); 177 folderView->refreshCurrent();
176 } else { 178 } else {
177 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 179 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
178 } 180 }
179} 181}
180 182
181void MainWindow::slotDeleteMail() 183void MainWindow::slotDeleteMail()
182{ 184{
183 if (!mailView->currentItem()) return; 185 if (!mailView->currentItem()) return;
184 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 186 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
185 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 ) { 187 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 ) {
186 mail.Wrapper()->deleteMail( mail ); 188 mail.Wrapper()->deleteMail( mail );
187 folderView->refreshCurrent(); 189 folderView->refreshCurrent();
188 } 190 }
189} 191}
190 192
191 193
192 194
193MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 195MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
194 :QListViewItem(parent,item),mail_data() 196 :QListViewItem(parent,item),mail_data()
195{ 197{
196} 198}
197 199
198void MailListViewItem::showEntry() 200void MailListViewItem::showEntry()
199{ 201{
200 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 202 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
201 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 203 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
202 } else { 204 } else {
203 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); 205 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") );
204 } 206 }
205 setText(1,mail_data.getSubject()); 207 setText(1,mail_data.getSubject());
206 setText(2,mail_data.getFrom()); 208 setText(2,mail_data.getFrom());
207 setText(3,mail_data.getDate()); 209 setText(3,mail_data.getDate());
208} 210}
209 211
210void MailListViewItem::storeData(const RecMail&data) 212void MailListViewItem::storeData(const RecMail&data)
211{ 213{
212 mail_data = data; 214 mail_data = data;
213} 215}
214 216
215const RecMail& MailListViewItem::data()const 217const RecMail& MailListViewItem::data()const
216{ 218{
217 return mail_data; 219 return mail_data;
218} 220}
219 221
220 222