author | harlekin <harlekin> | 2003-12-14 00:20:38 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-14 00:20:38 (UTC) |
commit | ff2b84787e454f8a11aaef7a4ce18941ac0d28fd (patch) (unidiff) | |
tree | 44bf51f9a3935542cdcfa5dafcc212e4f01ee8ce /noncore/net/mail/mainwindow.cpp | |
parent | b0a71314013a3367767526b68928a7168b4ad460 (diff) | |
download | opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.zip opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.tar.gz opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.tar.bz2 |
deleting of mails working
Diffstat (limited to 'noncore/net/mail/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 29 |
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 | ||
107 | void MainWindow::slotAdjustLayout() { | 112 | void 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 | ||
132 | void MainWindow::slotShowFolders( bool show ) | 137 | void 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 | ||
144 | void MainWindow::refreshMailView(QList<RecMail>*list) | 149 | void 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 | } |
154 | void MainWindow::displayMail(QListViewItem*item) | 159 | void 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 | ||
181 | void 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 | |||
168 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 191 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
169 | :QListViewItem(parent,item),mail_data() | 192 | :QListViewItem(parent,item),mail_data() |
170 | { | 193 | { |
171 | } | 194 | } |
172 | 195 | ||
173 | void MailListViewItem::showEntry() | 196 | void 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 | } |