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