summaryrefslogtreecommitdiffabout
path: root/kmicromail/mainwindow.cpp
authorzautrix <zautrix>2004-07-03 16:33:12 (UTC)
committer zautrix <zautrix>2004-07-03 16:33:12 (UTC)
commite3b89230f065c48c84b48c88edb6eb088374c487 (patch) (unidiff)
tree162ea2ef909a6f82ccfcedf45d80d6c821174912 /kmicromail/mainwindow.cpp
parent2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff)
downloadkdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2
Initial revision
Diffstat (limited to 'kmicromail/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/mainwindow.cpp232
1 files changed, 232 insertions, 0 deletions
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
new file mode 100644
index 0000000..78377ea
--- a/dev/null
+++ b/kmicromail/mainwindow.cpp
@@ -0,0 +1,232 @@
1#include <qlabel.h>
2#include <qvbox.h>
3#include <qheader.h>
4#include <qtimer.h>
5#include <qlayout.h>
6#include <kdialog.h>
7#include <kiconloader.h>
8
9#ifndef DESKTOP_VERSION
10#include <qpe/qpeapplication.h>
11#endif
12#include "defines.h"
13#include "mainwindow.h"
14#include <KDGanttMinimizeSplitter.h>
15
16
17#include <kabc/stdaddressbook.h>
18
19MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
20 : QMainWindow( parent, name, flags )
21{
22 setCaption( tr( "KMicroMail" ) );
23 setToolBarsMovable( false );
24 KABC::StdAddressBook::self();
25 toolBar = new QToolBar( this );
26 menuBar = new QMenuBar( toolBar );
27 mailMenu = new QPopupMenu( menuBar );
28 menuBar->insertItem( tr( "Mail" ), mailMenu );
29 settingsMenu = new QPopupMenu( menuBar );
30 menuBar->insertItem( tr( "Settings" ), settingsMenu );
31
32 addToolBar( toolBar );
33 toolBar->setHorizontalStretchable( true );
34
35 QLabel *spacer = new QLabel( toolBar );
36 spacer->setBackgroundMode( QWidget::PaletteButton );
37 toolBar->setStretchableWidget( spacer );
38
39 composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"),
40 0, 0, this );
41 composeMail->addTo( toolBar );
42 composeMail->addTo( mailMenu );
43
44 sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("sendqueued") ,
45 0, 0, this );
46 sendQueued->addTo( toolBar );
47 sendQueued->addTo( mailMenu );
48
49 /*
50 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
51 0, 0, this );
52 syncFolders->addTo( toolBar );
53 syncFolders->addTo( mailMenu );
54 */
55
56 showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") ,
57 0, 0, this, 0, true );
58 showFolders->addTo( toolBar );
59 showFolders->addTo( mailMenu );
60 showFolders->setOn( true );
61 connect(showFolders, SIGNAL( toggled(bool) ),
62 SLOT( slotShowFolders(bool) ) );
63
64 /*
65 searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ),
66 0, 0, this );
67 searchMails->addTo( toolBar );
68 searchMails->addTo( mailMenu );
69 */
70
71 deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this);
72 deleteMails->addTo( toolBar );
73 deleteMails->addTo( mailMenu );
74 connect( deleteMails, SIGNAL( activated() ),
75 SLOT( slotDeleteMail() ) );
76
77 editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") ,
78 0, 0, this );
79 editSettings->addTo( settingsMenu );
80 connect( editSettings, SIGNAL( activated() ),
81 SLOT( slotEditSettings() ) );
82 editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") ,
83 0, 0, this );
84 editAccounts->addTo( settingsMenu );
85
86 //setCentralWidget( view );
87
88 QVBox* wrapperBox = new QVBox( this );
89 setCentralWidget( wrapperBox );
90
91 // QWidget *view = new QWidget( wrapperBox );
92 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
93 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
94 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
95
96 folderView = new AccountView( split );
97 folderView->header()->hide();
98 folderView->setRootIsDecorated( true );
99 folderView->addColumn( tr( "Mailbox" ) );
100
101 //layout->addWidget( folderView );
102
103 mailView = new QListView( split );
104 mailView->addColumn( tr( "" ) );
105 mailView->addColumn( tr( "Subject" ),QListView::Manual );
106 mailView->addColumn( tr( "Sender" ),QListView::Manual );
107 mailView->addColumn( tr( "Size" ),QListView::Manual);
108 mailView->addColumn( tr( "Date" ));
109 mailView->setAllColumnsShowFocus(true);
110 //mailView->setSorting(-1);
111
112 statusWidget = new StatusWidget( wrapperBox );
113 statusWidget->hide();
114
115 //layout->addWidget( mailView );
116 //layout->setStretchFactor( folderView, 1 );
117 //layout->setStretchFactor( mailView, 2 );
118
119 slotAdjustLayout();
120#ifndef DESKTOP_VERSION
121 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
122 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
123#endif
124 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this,
125 SLOT( mailLeftClicked(QListViewItem*) ) );
126 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this,
127 SLOT( mailLeftClicked(QListViewItem*) ) );
128 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
129 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
130 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
131 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
132 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
133 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
134// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
135 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
136 mailView->setMultiSelection ( true );
137 //mailView->setSelectionMode( QListView::Extended );
138 QValueList<int> list;
139 int fw = 100;
140 if ( QApplication::desktop()->width() > 320 )
141 fw = 50;
142 list.append( fw );
143 list.append( 100 );
144 split->setSizes( list );
145 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
146 mailView->setShowSortIndicator ( true );
147}
148
149MainWindow::~MainWindow()
150{
151}
152
153void MainWindow::appMessage(const QCString &, const QByteArray &)
154{
155 qDebug("appMessage implemented by subclass");
156}
157
158void MainWindow::slotAdjustLayout() {
159
160 /*
161 QWidget *d = QApplication::desktop();
162
163 if ( d->width() < d->height() ) {
164 layout->setDirection( QBoxLayout::TopToBottom );
165 } else {
166 layout->setDirection( QBoxLayout::LeftToRight );
167 }
168 */
169}
170
171void MainWindow::slotAdjustColumns()
172{
173 bool hidden = folderView->isHidden();
174 if ( hidden ) folderView->show();
175 folderView->setColumnWidth( 0, folderView->visibleWidth() );
176 if ( hidden ) folderView->hide();
177
178 mailView->setColumnWidth( 0, 10 );
179 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
180 mailView->setColumnWidth( 2, 80 );
181 mailView->setColumnWidth( 3, 50 );
182 mailView->setColumnWidth( 4, 50 );
183}
184
185void MainWindow::slotEditSettings()
186{
187}
188
189void MainWindow::slotShowFolders( bool )
190{
191 qDebug("not implemented: ");
192}
193
194void MainWindow::refreshMailView(const QValueList<RecMailP>&)
195{
196 qDebug("not implemented: ");
197}
198
199void MainWindow::mailLeftClicked(QListViewItem * )
200{
201 qDebug("not implemented: ");
202}
203
204void MainWindow::displayMail()
205{
206 qDebug("not implemented: ");
207}
208
209void MainWindow::slotDeleteMail()
210{
211 qDebug("not implemented: ");
212}
213
214void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
215{
216 qDebug("not implemented: ");
217}
218
219void MainWindow::slotSendQueued()
220{
221 qDebug("not implemented: ");
222}
223
224void MainWindow::slotEditAccounts()
225{
226 qDebug("not implemented: ");
227}
228
229void MainWindow::slotComposeMail()
230{
231 qDebug("not implemented: ");
232}