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