summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 6e8f4d3..7af7d83 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,155 +1,171 @@
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 6
7#include <qpe/qpeapplication.h>
6 8
7#include "defines.h" 9#include "defines.h"
8#include "mainwindow.h" 10#include "mainwindow.h"
9#include "viewmail.h" 11#include "viewmail.h"
10 12
11MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 13MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
12 : QMainWindow( parent, name, flags ) 14 : QMainWindow( parent, name, flags )
13{ 15{
14 setCaption( tr( "Opie-Mail" ) ); 16 setCaption( tr( "Opie-Mail" ) );
15 setToolBarsMovable( false ); 17 setToolBarsMovable( false );
16 18
17 toolBar = new QToolBar( this ); 19 toolBar = new QToolBar( this );
18 menuBar = new QMenuBar( toolBar ); 20 menuBar = new QMenuBar( toolBar );
19 mailMenu = new QPopupMenu( menuBar ); 21 mailMenu = new QPopupMenu( menuBar );
20 menuBar->insertItem( tr( "Mail" ), mailMenu ); 22 menuBar->insertItem( tr( "Mail" ), mailMenu );
21 settingsMenu = new QPopupMenu( menuBar ); 23 settingsMenu = new QPopupMenu( menuBar );
22 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 24 menuBar->insertItem( tr( "Settings" ), settingsMenu );
23 25
24 addToolBar( toolBar ); 26 addToolBar( toolBar );
25 toolBar->setHorizontalStretchable( true ); 27 toolBar->setHorizontalStretchable( true );
26 28
27 QLabel *spacer = new QLabel( toolBar ); 29 QLabel *spacer = new QLabel( toolBar );
28 spacer->setBackgroundMode( QWidget::PaletteButton ); 30 spacer->setBackgroundMode( QWidget::PaletteButton );
29 toolBar->setStretchableWidget( spacer ); 31 toolBar->setStretchableWidget( spacer );
30 32
31 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 33 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
32 0, 0, this ); 34 0, 0, this );
33 composeMail->addTo( toolBar ); 35 composeMail->addTo( toolBar );
34 composeMail->addTo( mailMenu ); 36 composeMail->addTo( mailMenu );
35 37
36 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 38 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
37 0, 0, this ); 39 0, 0, this );
38 sendQueued->addTo( toolBar ); 40 sendQueued->addTo( toolBar );
39 sendQueued->addTo( mailMenu ); 41 sendQueued->addTo( mailMenu );
40 42
41 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 43 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
42 0, 0, this ); 44 0, 0, this );
43 syncFolders->addTo( toolBar ); 45 syncFolders->addTo( toolBar );
44 syncFolders->addTo( mailMenu ); 46 syncFolders->addTo( mailMenu );
45 47
46 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 48 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
47 0, 0, this, 0, true ); 49 0, 0, this, 0, true );
48 showFolders->addTo( toolBar ); 50 showFolders->addTo( toolBar );
49 showFolders->addTo( mailMenu ); 51 showFolders->addTo( mailMenu );
50 connect(showFolders, SIGNAL( toggled( bool ) ), 52 connect(showFolders, SIGNAL( toggled( bool ) ),
51 SLOT( slotShowFolders( bool ) ) ); 53 SLOT( slotShowFolders( bool ) ) );
52 54
53 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 55 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS,
54 0, 0, this ); 56 0, 0, this );
55 searchMails->addTo( toolBar ); 57 searchMails->addTo( toolBar );
56 searchMails->addTo( mailMenu ); 58 searchMails->addTo( mailMenu );
57 59
58 60
59 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 61 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
60 0, 0, this ); 62 0, 0, this );
61 editSettings->addTo( settingsMenu ); 63 editSettings->addTo( settingsMenu );
62 64
63 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 65 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
64 0, 0, this ); 66 0, 0, this );
65 editAccounts->addTo( settingsMenu ); 67 editAccounts->addTo( settingsMenu );
66 68
67 QVBox *view = new QVBox( this ); 69 QWidget *view = new QWidget( this );
68 setCentralWidget( view ); 70 setCentralWidget( view );
69 71
72
73 QWidget *d = QApplication::desktop();
74 QBoxLayout *layout;
75
76 if ( d->width() < d->height() ) {
77 layout = new QVBoxLayout( view );
78 } else {
79 layout = new QHBoxLayout( view );
80 }
81
70 folderView = new AccountView( view ); 82 folderView = new AccountView( view );
71 folderView->header()->hide(); 83 folderView->header()->hide();
72 folderView->setMinimumHeight( 90 );
73 folderView->setMaximumHeight( 90 );
74 folderView->addColumn( tr( "Mailbox" ) ); 84 folderView->addColumn( tr( "Mailbox" ) );
75 folderView->hide(); 85 folderView->hide();
76 86
87 layout->addWidget( folderView );
88
77 mailView = new QListView( view ); 89 mailView = new QListView( view );
78 mailView->setMinimumHeight( 50 );
79 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 90 mailView->addColumn( tr( "Subject" ),QListView::Manual );
80 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 91 mailView->addColumn( tr( "Sender" ),QListView::Manual );
81 mailView->addColumn( tr( "Date" )); 92 mailView->addColumn( tr( "Date" ));
82 mailView->setAllColumnsShowFocus(true); 93 mailView->setAllColumnsShowFocus(true);
83 mailView->setSorting(-1); 94 mailView->setSorting(-1);
95
96 layout->addWidget( mailView );
97 layout->setStretchFactor( folderView, 1 );
98 layout->setStretchFactor( mailView, 2 );
99
84 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, 100 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
85 SLOT( displayMail( QListViewItem * ) ) ); 101 SLOT( displayMail( QListViewItem * ) ) );
86 102
87 connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*))); 103 connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*)));
88 104
89 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 105 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
90} 106}
91 107
92void MainWindow::slotAdjustColumns() 108void MainWindow::slotAdjustColumns()
93{ 109{
94 bool hidden = folderView->isHidden(); 110 bool hidden = folderView->isHidden();
95 if ( hidden ) folderView->show(); 111 if ( hidden ) folderView->show();
96 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 112 folderView->setColumnWidth( 0, folderView->visibleWidth() );
97 if ( hidden ) folderView->hide(); 113 if ( hidden ) folderView->hide();
98 114
99 mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); 115 mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 );
100 mailView->setColumnWidth( 1, 80 ); 116 mailView->setColumnWidth( 1, 80 );
101 mailView->setColumnWidth( 2, 50 ); 117 mailView->setColumnWidth( 2, 50 );
102} 118}
103 119
104void MainWindow::slotShowFolders( bool show ) 120void MainWindow::slotShowFolders( bool show )
105{ 121{
106 qDebug( "Show Folders" ); 122 qDebug( "Show Folders" );
107 if ( show && folderView->isHidden() ) { 123 if ( show && folderView->isHidden() ) {
108 qDebug( "-> showing" ); 124 qDebug( "-> showing" );
109 folderView->show(); 125 folderView->show();
110 } else if ( !show && !folderView->isHidden() ) { 126 } else if ( !show && !folderView->isHidden() ) {
111 qDebug( "-> hiding" ); 127 qDebug( "-> hiding" );
112 folderView->hide(); 128 folderView->hide();
113 } 129 }
114} 130}
115 131
116void MainWindow::refreshMailView(Maillist*list) 132void MainWindow::refreshMailView(Maillist*list)
117{ 133{
118 MailListViewItem*item = 0; 134 MailListViewItem*item = 0;
119 mailView->clear(); 135 mailView->clear();
120#if 0 136#if 0
121 QFont f = mailView->getFont(); 137 QFont f = mailView->getFont();
122 QFont bf = f; 138 QFont bf = f;
123#endif 139#endif
124 for (unsigned int i = 0; i < list->count();++i) { 140 for (unsigned int i = 0; i < list->count();++i) {
125 item = new MailListViewItem(mailView,item); 141 item = new MailListViewItem(mailView,item);
126 item->storeData(*(list->at(i))); 142 item->storeData(*(list->at(i)));
127 item->showEntry(); 143 item->showEntry();
128#if 0 144#if 0
129 if (!list->at(i)->getFlags().testBit(FLAG_SEEN)) { 145 if (!list->at(i)->getFlags().testBit(FLAG_SEEN)) {
130 item->setFont(bf); 146 item->setFont(bf);
131 } 147 }
132#endif 148#endif
133 } 149 }
134} 150}
135void MainWindow::displayMail(QListViewItem*item) 151void MainWindow::displayMail(QListViewItem*item)
136{ 152{
137 if (!item) return; 153 if (!item) return;
138 qDebug("View mail"); 154 qDebug("View mail");
139 RecMail mail = ((MailListViewItem*)item)->data(); 155 RecMail mail = ((MailListViewItem*)item)->data();
140 QString body = folderView->fetchBody(mail); 156 QString body = folderView->fetchBody(mail);
141 157
142 ViewMail readMail( this ); 158 ViewMail readMail( this );
143 readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body ); 159 readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body );
144 readMail.showMaximized(); 160 readMail.showMaximized();
145 readMail.exec(); 161 readMail.exec();
146 162
147 qDebug(body ); 163 qDebug(body );
148} 164}
149 165
150void MailListViewItem::showEntry() 166void MailListViewItem::showEntry()
151{ 167{
152 setText(0,mail_data.getSubject()); 168 setText(0,mail_data.getSubject());
153 setText(1,mail_data.getFrom()); 169 setText(1,mail_data.getFrom());
154 setText(2,mail_data.getDate()); 170 setText(2,mail_data.getDate());
155} 171}