-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 3c659e4..d2e887b 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,212 +1,212 @@ | |||
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 | 12 | ||
13 | #include "defines.h" | 13 | #include "defines.h" |
14 | #include "mainwindow.h" | 14 | #include "mainwindow.h" |
15 | #include "viewmail.h" | 15 | #include "viewmail.h" |
16 | #include <libmailwrapper/mailtypes.h> | 16 | #include <libmailwrapper/mailtypes.h> |
17 | #include "mailistviewitem.h" | 17 | #include "mailistviewitem.h" |
18 | 18 | ||
19 | 19 | ||
20 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 20 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
21 | : QMainWindow( parent, name, flags ) | 21 | : QMainWindow( parent, name, flags ) |
22 | { | 22 | { |
23 | 23 | ||
24 | setCaption( tr( "Mail" ) ); | 24 | setCaption( tr( "Mail" ) ); |
25 | setToolBarsMovable( false ); | 25 | setToolBarsMovable( false ); |
26 | 26 | ||
27 | toolBar = new QToolBar( this ); | 27 | toolBar = new QToolBar( this ); |
28 | menuBar = new QMenuBar( toolBar ); | 28 | menuBar = new QMenuBar( toolBar ); |
29 | mailMenu = new QPopupMenu( menuBar ); | 29 | mailMenu = new QPopupMenu( menuBar ); |
30 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 30 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
31 | settingsMenu = new QPopupMenu( menuBar ); | 31 | settingsMenu = new QPopupMenu( menuBar ); |
32 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 32 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
33 | 33 | ||
34 | addToolBar( toolBar ); | 34 | addToolBar( toolBar ); |
35 | toolBar->setHorizontalStretchable( true ); | 35 | toolBar->setHorizontalStretchable( true ); |
36 | 36 | ||
37 | QLabel *spacer = new QLabel( toolBar ); | 37 | QLabel *spacer = new QLabel( toolBar ); |
38 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 38 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
39 | toolBar->setStretchableWidget( spacer ); | 39 | toolBar->setStretchableWidget( spacer ); |
40 | 40 | ||
41 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 41 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
42 | 0, 0, this ); | 42 | 0, 0, this ); |
43 | composeMail->addTo( toolBar ); | 43 | composeMail->addTo( toolBar ); |
44 | composeMail->addTo( mailMenu ); | 44 | composeMail->addTo( mailMenu ); |
45 | 45 | ||
46 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 46 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
47 | 0, 0, this ); | 47 | 0, 0, this ); |
48 | sendQueued->addTo( toolBar ); | 48 | sendQueued->addTo( toolBar ); |
49 | sendQueued->addTo( mailMenu ); | 49 | sendQueued->addTo( mailMenu ); |
50 | 50 | ||
51 | /* | 51 | /* |
52 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 52 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
53 | 0, 0, this ); | 53 | 0, 0, this ); |
54 | syncFolders->addTo( toolBar ); | 54 | syncFolders->addTo( toolBar ); |
55 | syncFolders->addTo( mailMenu ); | 55 | syncFolders->addTo( mailMenu ); |
56 | */ | 56 | */ |
57 | 57 | ||
58 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 58 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
59 | 0, 0, this, 0, true ); | 59 | 0, 0, this, 0, true ); |
60 | showFolders->addTo( toolBar ); | 60 | showFolders->addTo( toolBar ); |
61 | showFolders->addTo( mailMenu ); | 61 | showFolders->addTo( mailMenu ); |
62 | showFolders->setOn( true ); | 62 | showFolders->setOn( true ); |
63 | connect(showFolders, SIGNAL( toggled( bool ) ), | 63 | connect(showFolders, SIGNAL( toggled( bool ) ), |
64 | SLOT( slotShowFolders( bool ) ) ); | 64 | SLOT( slotShowFolders( bool ) ) ); |
65 | 65 | ||
66 | /* | 66 | /* |
67 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), | 67 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), |
68 | 0, 0, this ); | 68 | 0, 0, this ); |
69 | searchMails->addTo( toolBar ); | 69 | searchMails->addTo( toolBar ); |
70 | searchMails->addTo( mailMenu ); | 70 | searchMails->addTo( mailMenu ); |
71 | */ | 71 | */ |
72 | 72 | ||
73 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); | 73 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); |
74 | deleteMails->addTo( toolBar ); | 74 | deleteMails->addTo( toolBar ); |
75 | deleteMails->addTo( mailMenu ); | 75 | deleteMails->addTo( mailMenu ); |
76 | connect( deleteMails, SIGNAL( activated() ), | 76 | connect( deleteMails, SIGNAL( activated() ), |
77 | SLOT( slotDeleteMail() ) ); | 77 | SLOT( slotDeleteMail() ) ); |
78 | 78 | ||
79 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , | 79 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , |
80 | 0, 0, this ); | 80 | 0, 0, this ); |
81 | editSettings->addTo( settingsMenu ); | 81 | editSettings->addTo( settingsMenu ); |
82 | connect( editSettings, SIGNAL( activated() ), | 82 | connect( editSettings, SIGNAL( activated() ), |
83 | SLOT( slotEditSettings() ) ); | 83 | SLOT( slotEditSettings() ) ); |
84 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , | 84 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , |
85 | 0, 0, this ); | 85 | 0, 0, this ); |
86 | editAccounts->addTo( settingsMenu ); | 86 | editAccounts->addTo( settingsMenu ); |
87 | 87 | ||
88 | //setCentralWidget( view ); | 88 | //setCentralWidget( view ); |
89 | 89 | ||
90 | QVBox* wrapperBox = new QVBox( this ); | 90 | QVBox* wrapperBox = new QVBox( this ); |
91 | setCentralWidget( wrapperBox ); | 91 | setCentralWidget( wrapperBox ); |
92 | 92 | ||
93 | QWidget *view = new QWidget( wrapperBox ); | 93 | QWidget *view = new QWidget( wrapperBox ); |
94 | 94 | ||
95 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 95 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
96 | 96 | ||
97 | folderView = new AccountView( view ); | 97 | folderView = new AccountView( view ); |
98 | folderView->header()->hide(); | 98 | folderView->header()->hide(); |
99 | folderView->setRootIsDecorated( true ); | 99 | folderView->setRootIsDecorated( true ); |
100 | folderView->addColumn( tr( "Mailbox" ) ); | 100 | folderView->addColumn( tr( "Mailbox" ) ); |
101 | 101 | ||
102 | layout->addWidget( folderView ); | 102 | layout->addWidget( folderView ); |
103 | 103 | ||
104 | mailView = new QListView( view ); | 104 | mailView = new QListView( view ); |
105 | mailView->addColumn( tr( "" ) ); | 105 | mailView->addColumn( tr( "" ) ); |
106 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 106 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
107 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 107 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
108 | mailView->addColumn( tr( "Size" ),QListView::Manual); | 108 | mailView->addColumn( tr( "Size" ),QListView::Manual); |
109 | mailView->addColumn( tr( "Date" )); | 109 | mailView->addColumn( tr( "Date" )); |
110 | mailView->setAllColumnsShowFocus(true); | 110 | mailView->setAllColumnsShowFocus(true); |
111 | mailView->setSorting(-1); | 111 | mailView->setSorting(-1); |
112 | 112 | ||
113 | statusWidget = new StatusWidget( wrapperBox ); | 113 | statusWidget = new StatusWidget( wrapperBox ); |
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 | slotAdjustLayout(); | 120 | slotAdjustLayout(); |
121 | 121 | ||
122 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 122 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
123 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 123 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
124 | 124 | ||
125 | connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, | 125 | connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, |
126 | SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); | 126 | SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); |
127 | connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 127 | connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
128 | SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); | 128 | SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); |
129 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 129 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
130 | 130 | ||
131 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 131 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | void MainWindow::slotAdjustLayout() { | 135 | void MainWindow::slotAdjustLayout() { |
136 | 136 | ||
137 | QWidget *d = QApplication::desktop(); | 137 | QWidget *d = QApplication::desktop(); |
138 | 138 | ||
139 | if ( d->width() < d->height() ) { | 139 | if ( d->width() < d->height() ) { |
140 | layout->setDirection( QBoxLayout::TopToBottom ); | 140 | layout->setDirection( QBoxLayout::TopToBottom ); |
141 | } else { | 141 | } else { |
142 | layout->setDirection( QBoxLayout::LeftToRight ); | 142 | layout->setDirection( QBoxLayout::LeftToRight ); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void MainWindow::slotAdjustColumns() | 146 | void MainWindow::slotAdjustColumns() |
147 | { | 147 | { |
148 | bool hidden = folderView->isHidden(); | 148 | bool hidden = folderView->isHidden(); |
149 | if ( hidden ) folderView->show(); | 149 | if ( hidden ) folderView->show(); |
150 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 150 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
151 | if ( hidden ) folderView->hide(); | 151 | if ( hidden ) folderView->hide(); |
152 | 152 | ||
153 | mailView->setColumnWidth( 0, 10 ); | 153 | mailView->setColumnWidth( 0, 10 ); |
154 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 154 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
155 | mailView->setColumnWidth( 2, 80 ); | 155 | mailView->setColumnWidth( 2, 80 ); |
156 | mailView->setColumnWidth( 3, 50 ); | 156 | mailView->setColumnWidth( 3, 50 ); |
157 | mailView->setColumnWidth( 4, 50 ); | 157 | mailView->setColumnWidth( 4, 50 ); |
158 | } | 158 | } |
159 | 159 | ||
160 | void MainWindow::slotEditSettings() | 160 | void MainWindow::slotEditSettings() |
161 | { | 161 | { |
162 | } | 162 | } |
163 | 163 | ||
164 | void MainWindow::slotShowFolders( bool show ) | 164 | void MainWindow::slotShowFolders( bool show ) |
165 | { | 165 | { |
166 | qDebug( "Show Folders" ); | 166 | qDebug( "Show Folders" ); |
167 | if ( show && folderView->isHidden() ) { | 167 | if ( show && folderView->isHidden() ) { |
168 | qDebug( "-> showing" ); | 168 | qDebug( "-> showing" ); |
169 | folderView->show(); | 169 | folderView->show(); |
170 | } else if ( !show && !folderView->isHidden() ) { | 170 | } else if ( !show && !folderView->isHidden() ) { |
171 | qDebug( "-> hiding" ); | 171 | qDebug( "-> hiding" ); |
172 | folderView->hide(); | 172 | folderView->hide(); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | void MainWindow::refreshMailView(QList<RecMail>*list) | 176 | void MainWindow::refreshMailView(QList<RecMail>*list) |
177 | { | 177 | { |
178 | MailListViewItem*item = 0; | 178 | MailListViewItem*item = 0; |
179 | mailView->clear(); | 179 | mailView->clear(); |
180 | for (unsigned int i = 0; i < list->count();++i) { | 180 | for (unsigned int i = 0; i < list->count();++i) { |
181 | item = new MailListViewItem(mailView,item); | 181 | item = new MailListViewItem(mailView,item); |
182 | item->storeData(*(list->at(i))); | 182 | item->storeData(*(list->at(i))); |
183 | item->showEntry(); | 183 | item->showEntry(); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | 186 | void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) |
187 | { | 187 | { |
188 | /* just LEFT button - or tap with stylus on pda */ | 188 | /* just LEFT button - or tap with stylus on pda */ |
189 | if (button!=1) return; | 189 | if (button!=1) return; |
190 | if (!item) return; | 190 | if (!item) return; |
191 | displayMail(); | 191 | displayMail(); |
192 | } | 192 | } |
193 | 193 | ||
194 | void MainWindow::displayMail() | 194 | void MainWindow::displayMail() |
195 | { | 195 | { |
196 | QListViewItem*item = mailView->currentItem(); | 196 | QListViewItem*item = mailView->currentItem(); |
197 | if (!item) return; | 197 | if (!item) return; |
198 | RecMail mail = ((MailListViewItem*)item)->data(); | 198 | RecMail mail = ((MailListViewItem*)item)->data(); |
199 | RecBody body = folderView->fetchBody(mail); | 199 | RecBody body = folderView->fetchBody(mail); |
200 | ViewMail readMail( this ); | 200 | ViewMail readMail( this ); |
201 | readMail.setBody( body ); | 201 | readMail.setBody( body ); |
202 | readMail.setMail( mail ); | 202 | readMail.setMail( mail ); |
203 | readMail.showMaximized(); | 203 | readMail.showMaximized(); |
204 | readMail.exec(); | 204 | readMail.exec(); |
205 | 205 | ||
206 | if ( readMail.deleted ) { | 206 | if ( readMail.deleted ) { |
207 | folderView->refreshCurrent(); | 207 | folderView->refreshCurrent(); |
208 | } else { | 208 | } else { |
209 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); | 209 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||