Diffstat (limited to 'noncore/net/mail/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 2a74286..6511b1f 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,69 +1,70 @@ | |||
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 | #include "defines.h" | 12 | #include "defines.h" |
13 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
14 | #include "viewmail.h" | 14 | #include "viewmail.h" |
15 | #include "mailtypes.h" | 15 | #include "mailtypes.h" |
16 | #include "mailistviewitem.h" | 16 | #include "mailistviewitem.h" |
17 | 17 | ||
18 | 18 | ||
19 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 19 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
20 | : QMainWindow( parent, name, flags ) | 20 | : QMainWindow( parent, name, flags ) |
21 | { | 21 | { |
22 | |||
22 | setCaption( tr( "Mail" ) ); | 23 | setCaption( tr( "Mail" ) ); |
23 | setToolBarsMovable( false ); | 24 | setToolBarsMovable( false ); |
24 | 25 | ||
25 | toolBar = new QToolBar( this ); | 26 | toolBar = new QToolBar( this ); |
26 | menuBar = new QMenuBar( toolBar ); | 27 | menuBar = new QMenuBar( toolBar ); |
27 | mailMenu = new QPopupMenu( menuBar ); | 28 | mailMenu = new QPopupMenu( menuBar ); |
28 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 29 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
29 | settingsMenu = new QPopupMenu( menuBar ); | 30 | settingsMenu = new QPopupMenu( menuBar ); |
30 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 31 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
31 | 32 | ||
32 | addToolBar( toolBar ); | 33 | addToolBar( toolBar ); |
33 | toolBar->setHorizontalStretchable( true ); | 34 | toolBar->setHorizontalStretchable( true ); |
34 | 35 | ||
35 | QLabel *spacer = new QLabel( toolBar ); | 36 | QLabel *spacer = new QLabel( toolBar ); |
36 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 37 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
37 | toolBar->setStretchableWidget( spacer ); | 38 | toolBar->setStretchableWidget( spacer ); |
38 | 39 | ||
39 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 40 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
40 | 0, 0, this ); | 41 | 0, 0, this ); |
41 | composeMail->addTo( toolBar ); | 42 | composeMail->addTo( toolBar ); |
42 | composeMail->addTo( mailMenu ); | 43 | composeMail->addTo( mailMenu ); |
43 | 44 | ||
44 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 45 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
45 | 0, 0, this ); | 46 | 0, 0, this ); |
46 | sendQueued->addTo( toolBar ); | 47 | sendQueued->addTo( toolBar ); |
47 | sendQueued->addTo( mailMenu ); | 48 | sendQueued->addTo( mailMenu ); |
48 | 49 | ||
49 | /* | 50 | /* |
50 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 51 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
51 | 0, 0, this ); | 52 | 0, 0, this ); |
52 | syncFolders->addTo( toolBar ); | 53 | syncFolders->addTo( toolBar ); |
53 | syncFolders->addTo( mailMenu ); | 54 | syncFolders->addTo( mailMenu ); |
54 | */ | 55 | */ |
55 | 56 | ||
56 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 57 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
57 | 0, 0, this, 0, true ); | 58 | 0, 0, this, 0, true ); |
58 | showFolders->addTo( toolBar ); | 59 | showFolders->addTo( toolBar ); |
59 | showFolders->addTo( mailMenu ); | 60 | showFolders->addTo( mailMenu ); |
60 | showFolders->setOn( true ); | 61 | showFolders->setOn( true ); |
61 | connect(showFolders, SIGNAL( toggled( bool ) ), | 62 | connect(showFolders, SIGNAL( toggled( bool ) ), |
62 | SLOT( slotShowFolders( bool ) ) ); | 63 | SLOT( slotShowFolders( bool ) ) ); |
63 | 64 | ||
64 | /* | 65 | /* |
65 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, | 66 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, |
66 | 0, 0, this ); | 67 | 0, 0, this ); |
67 | searchMails->addTo( toolBar ); | 68 | searchMails->addTo( toolBar ); |
68 | searchMails->addTo( mailMenu ); | 69 | searchMails->addTo( mailMenu ); |
69 | */ | 70 | */ |
@@ -71,104 +72,104 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
71 | deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); | 72 | deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); |
72 | deleteMails->addTo( toolBar ); | 73 | deleteMails->addTo( toolBar ); |
73 | deleteMails->addTo( mailMenu ); | 74 | deleteMails->addTo( mailMenu ); |
74 | connect( deleteMails, SIGNAL( activated() ), | 75 | connect( deleteMails, SIGNAL( activated() ), |
75 | SLOT( slotDeleteMail() ) ); | 76 | SLOT( slotDeleteMail() ) ); |
76 | 77 | ||
77 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, | 78 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, |
78 | 0, 0, this ); | 79 | 0, 0, this ); |
79 | editSettings->addTo( settingsMenu ); | 80 | editSettings->addTo( settingsMenu ); |
80 | connect( editSettings, SIGNAL( activated() ), | 81 | connect( editSettings, SIGNAL( activated() ), |
81 | SLOT( slotEditSettings() ) ); | 82 | SLOT( slotEditSettings() ) ); |
82 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, | 83 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, |
83 | 0, 0, this ); | 84 | 0, 0, this ); |
84 | editAccounts->addTo( settingsMenu ); | 85 | editAccounts->addTo( settingsMenu ); |
85 | 86 | ||
86 | //setCentralWidget( view ); | 87 | //setCentralWidget( view ); |
87 | 88 | ||
88 | QVBox* wrapperBox = new QVBox( this ); | 89 | QVBox* wrapperBox = new QVBox( this ); |
89 | setCentralWidget( wrapperBox ); | 90 | setCentralWidget( wrapperBox ); |
90 | 91 | ||
91 | QWidget *view = new QWidget( wrapperBox ); | 92 | QWidget *view = new QWidget( wrapperBox ); |
92 | 93 | ||
93 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 94 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
94 | 95 | ||
95 | folderView = new AccountView( view ); | 96 | folderView = new AccountView( view ); |
96 | folderView->header()->hide(); | 97 | folderView->header()->hide(); |
97 | folderView->setRootIsDecorated( true ); | 98 | folderView->setRootIsDecorated( true ); |
98 | folderView->addColumn( tr( "Mailbox" ) ); | 99 | folderView->addColumn( tr( "Mailbox" ) ); |
99 | 100 | ||
100 | layout->addWidget( folderView ); | 101 | layout->addWidget( folderView ); |
101 | 102 | ||
102 | mailView = new QListView( view ); | 103 | mailView = new QListView( view ); |
103 | mailView->addColumn( tr( "" ) ); | 104 | mailView->addColumn( tr( "" ) ); |
104 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 105 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
105 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 106 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
106 | mailView->addColumn( tr( "Size" ),QListView::Manual); | 107 | mailView->addColumn( tr( "Size" ),QListView::Manual); |
107 | mailView->addColumn( tr( "Date" )); | 108 | mailView->addColumn( tr( "Date" )); |
108 | mailView->setAllColumnsShowFocus(true); | 109 | mailView->setAllColumnsShowFocus(true); |
109 | mailView->setSorting(-1); | 110 | mailView->setSorting(-1); |
110 | 111 | ||
111 | statusWidget = new StatusWidget( wrapperBox ); | 112 | statusWidget = new StatusWidget( wrapperBox ); |
112 | statusWidget->hide(); | 113 | statusWidget->hide(); |
113 | 114 | ||
114 | layout->addWidget( mailView ); | 115 | layout->addWidget( mailView ); |
115 | layout->setStretchFactor( folderView, 1 ); | 116 | layout->setStretchFactor( folderView, 1 ); |
116 | layout->setStretchFactor( mailView, 2 ); | 117 | layout->setStretchFactor( mailView, 2 ); |
117 | 118 | ||
118 | slotAdjustLayout(); | 119 | slotAdjustLayout(); |
119 | 120 | ||
120 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 121 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
121 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 122 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
122 | 123 | ||
123 | connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, | 124 | connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, |
124 | SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); | 125 | SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); |
125 | connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 126 | connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
126 | SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); | 127 | SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); |
127 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 128 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
128 | 129 | ||
129 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 130 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
130 | } | 131 | } |
131 | 132 | ||
132 | 133 | ||
133 | void MainWindow::slotAdjustLayout() { | 134 | void MainWindow::slotAdjustLayout() { |
134 | 135 | ||
135 | QWidget *d = QApplication::desktop(); | 136 | QWidget *d = QApplication::desktop(); |
136 | 137 | ||
137 | if ( d->width() < d->height() ) { | 138 | if ( d->width() < d->height() ) { |
138 | layout->setDirection( QBoxLayout::TopToBottom ); | 139 | layout->setDirection( QBoxLayout::TopToBottom ); |
139 | } else { | 140 | } else { |
140 | layout->setDirection( QBoxLayout::LeftToRight ); | 141 | layout->setDirection( QBoxLayout::LeftToRight ); |
141 | } | 142 | } |
142 | } | 143 | } |
143 | 144 | ||
144 | void MainWindow::slotAdjustColumns() | 145 | void MainWindow::slotAdjustColumns() |
145 | { | 146 | { |
146 | bool hidden = folderView->isHidden(); | 147 | bool hidden = folderView->isHidden(); |
147 | if ( hidden ) folderView->show(); | 148 | if ( hidden ) folderView->show(); |
148 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 149 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
149 | if ( hidden ) folderView->hide(); | 150 | if ( hidden ) folderView->hide(); |
150 | 151 | ||
151 | mailView->setColumnWidth( 0, 10 ); | 152 | mailView->setColumnWidth( 0, 10 ); |
152 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 153 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
153 | mailView->setColumnWidth( 2, 80 ); | 154 | mailView->setColumnWidth( 2, 80 ); |
154 | mailView->setColumnWidth( 3, 50 ); | 155 | mailView->setColumnWidth( 3, 50 ); |
155 | mailView->setColumnWidth( 4, 50 ); | 156 | mailView->setColumnWidth( 4, 50 ); |
156 | } | 157 | } |
157 | 158 | ||
158 | void MainWindow::slotEditSettings() | 159 | void MainWindow::slotEditSettings() |
159 | { | 160 | { |
160 | } | 161 | } |
161 | 162 | ||
162 | void MainWindow::slotShowFolders( bool show ) | 163 | void MainWindow::slotShowFolders( bool show ) |
163 | { | 164 | { |
164 | qDebug( "Show Folders" ); | 165 | qDebug( "Show Folders" ); |
165 | if ( show && folderView->isHidden() ) { | 166 | if ( show && folderView->isHidden() ) { |
166 | qDebug( "-> showing" ); | 167 | qDebug( "-> showing" ); |
167 | folderView->show(); | 168 | folderView->show(); |
168 | } else if ( !show && !folderView->isHidden() ) { | 169 | } else if ( !show && !folderView->isHidden() ) { |
169 | qDebug( "-> hiding" ); | 170 | qDebug( "-> hiding" ); |
170 | folderView->hide(); | 171 | folderView->hide(); |
171 | } | 172 | } |
172 | } | 173 | } |
173 | 174 | ||
174 | void MainWindow::refreshMailView(QList<RecMail>*list) | 175 | void MainWindow::refreshMailView(QList<RecMail>*list) |