summaryrefslogtreecommitdiff
path: root/noncore/net/mail/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 8ef7ddd..c410829 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -51,24 +51,29 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
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);
64 deleteMails->addTo( toolBar );
65 deleteMails->addTo( mailMenu );
66 connect( deleteMails, SIGNAL( activated() ),
67 SLOT( slotDeleteMail() ) );
63 68
64 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 69 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
65 0, 0, this ); 70 0, 0, this );
66 editSettings->addTo( settingsMenu ); 71 editSettings->addTo( settingsMenu );
67 72
68 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 73 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
69 0, 0, this ); 74 0, 0, this );
70 editAccounts->addTo( settingsMenu ); 75 editAccounts->addTo( settingsMenu );
71 76
72 QWidget *view = new QWidget( this ); 77 QWidget *view = new QWidget( this );
73 setCentralWidget( view ); 78 setCentralWidget( view );
74 79
@@ -89,25 +94,25 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
89 mailView->setAllColumnsShowFocus(true); 94 mailView->setAllColumnsShowFocus(true);
90 mailView->setSorting(-1); 95 mailView->setSorting(-1);
91 96
92 layout->addWidget( mailView ); 97 layout->addWidget( mailView );
93 layout->setStretchFactor( folderView, 1 ); 98 layout->setStretchFactor( folderView, 1 );
94 layout->setStretchFactor( mailView, 2 ); 99 layout->setStretchFactor( mailView, 2 );
95 100
96 slotAdjustLayout(); 101 slotAdjustLayout();
97 102
98 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, 103 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
99 SLOT( displayMail( QListViewItem * ) ) ); 104 SLOT( displayMail( QListViewItem * ) ) );
100 105
101 connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 106 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
102 107
103 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 108 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
104} 109}
105 110
106 111
107void MainWindow::slotAdjustLayout() { 112void MainWindow::slotAdjustLayout() {
108 113
109 QWidget *d = QApplication::desktop(); 114 QWidget *d = QApplication::desktop();
110 115
111 if ( d->width() < d->height() ) { 116 if ( d->width() < d->height() ) {
112 layout->setDirection( QBoxLayout::TopToBottom ); 117 layout->setDirection( QBoxLayout::TopToBottom );
113 } else { 118 } else {
@@ -122,58 +127,76 @@ void MainWindow::slotAdjustColumns()
122 if ( hidden ) folderView->show(); 127 if ( hidden ) folderView->show();
123 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 128 folderView->setColumnWidth( 0, folderView->visibleWidth() );
124 if ( hidden ) folderView->hide(); 129 if ( hidden ) folderView->hide();
125 130
126 mailView->setColumnWidth( 0, 10 ); 131 mailView->setColumnWidth( 0, 10 );
127 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 132 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
128 mailView->setColumnWidth( 2, 80 ); 133 mailView->setColumnWidth( 2, 80 );
129 mailView->setColumnWidth( 3, 50 ); 134 mailView->setColumnWidth( 3, 50 );
130} 135}
131 136
132void MainWindow::slotShowFolders( bool show ) 137void MainWindow::slotShowFolders( bool show )
133{ 138{
134 qDebug( "Show Folders" ); 139 qDebug( "Show Folders" );
135 if ( show && folderView->isHidden() ) { 140 if ( show && folderView->isHidden() ) {
136 qDebug( "-> showing" ); 141 qDebug( "-> showing" );
137 folderView->show(); 142 folderView->show();
138 } else if ( !show && !folderView->isHidden() ) { 143 } else if ( !show && !folderView->isHidden() ) {
139 qDebug( "-> hiding" ); 144 qDebug( "-> hiding" );
140 folderView->hide(); 145 folderView->hide();
141 } 146 }
142} 147}
143 148
144void MainWindow::refreshMailView(QList<RecMail>*list) 149void MainWindow::refreshMailView(QList<RecMail>*list)
145{ 150{
146 MailListViewItem*item = 0; 151 MailListViewItem*item = 0;
147 mailView->clear(); 152 mailView->clear();
148 for (unsigned int i = 0; i < list->count();++i) { 153 for (unsigned int i = 0; i < list->count();++i) {
149 item = new MailListViewItem(mailView,item); 154 item = new MailListViewItem(mailView,item);
150 item->storeData(*(list->at(i))); 155 item->storeData(*(list->at(i)));
151 item->showEntry(); 156 item->showEntry();
152 } 157 }
153} 158}
154void MainWindow::displayMail(QListViewItem*item) 159void MainWindow::displayMail(QListViewItem*item)
155{ 160{
161
162 m_currentItem = item;
163
156 if (!item) return; 164 if (!item) return;
157 RecMail mail = ((MailListViewItem*)item)->data(); 165 RecMail mail = ((MailListViewItem*)item)->data();
158 RecBody body = folderView->fetchBody(mail); 166 RecBody body = folderView->fetchBody(mail);
159 167
160 ViewMail readMail( this ); 168 ViewMail readMail( this );
161 readMail.setBody( body ); 169 readMail.setBody( body );
162 readMail.setMail( mail ); 170 readMail.setMail( mail );
163 readMail.showMaximized(); 171 readMail.showMaximized();
164 readMail.exec(); 172 readMail.exec();
165 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 173
174 if ( readMail.deleted ) {
175 folderView->refreshCurrent();
176 } else {
177 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
178 }
166} 179}
167 180
181void MainWindow::slotDeleteMail()
182{
183 if (!m_currentItem) return;
184 RecMail mail = ((MailListViewItem*)m_currentItem)->data();
185 mail.Wrapper()->deleteMail( mail );
186 folderView->refreshCurrent();
187}
188
189
190
168MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 191MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
169 :QListViewItem(parent,item),mail_data() 192 :QListViewItem(parent,item),mail_data()
170{ 193{
171} 194}
172 195
173void MailListViewItem::showEntry() 196void MailListViewItem::showEntry()
174{ 197{
175 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 198 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
176 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 199 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
177 } else { 200 } else {
178 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); 201 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") );
179 } 202 }