author | zautrix <zautrix> | 2005-08-23 09:58:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-23 09:58:25 (UTC) |
commit | e34e096c0e1b799904643c753591833f3ff2ab95 (patch) (unidiff) | |
tree | 7599dafddcc8b7b918ee52c5dfa1fe162d3022d3 /kmicromail/accountview.cpp | |
parent | cfda06568cbd0e67ba0188f00622b348b57b27c0 (diff) | |
download | kdepimpi-e34e096c0e1b799904643c753591833f3ff2ab95.zip kdepimpi-e34e096c0e1b799904643c753591833f3ff2ab95.tar.gz kdepimpi-e34e096c0e1b799904643c753591833f3ff2ab95.tar.bz2 |
ompi fix
-rw-r--r-- | kmicromail/accountview.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index cef55ab..4879d57 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp | |||
@@ -1,252 +1,263 @@ | |||
1 | 1 | ||
2 | #include "accountview.h" | 2 | #include "accountview.h" |
3 | #include "accountitem.h" | 3 | #include "accountitem.h" |
4 | #include "selectstore.h" | 4 | #include "selectstore.h" |
5 | 5 | ||
6 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | #include <libmailwrapper/mailwrapper.h> | 7 | #include <libmailwrapper/mailwrapper.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qpopupmenu.h> | 16 | #include <qpopupmenu.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qtimer.h> | 18 | #include <qtimer.h> |
19 | #include <qspinbox.h> | 19 | #include <qspinbox.h> |
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kmessagebox.h> | 21 | #include <kmessagebox.h> |
22 | 22 | ||
23 | using namespace Opie::Core; | 23 | using namespace Opie::Core; |
24 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 24 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
25 | : QListView( parent, name, flags ) | 25 | : QListView( parent, name, flags ) |
26 | { | 26 | { |
27 | //connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 27 | //connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
28 | // SLOT( refresh(QListViewItem*) ) ); | 28 | // SLOT( refresh(QListViewItem*) ) ); |
29 | connect( this, SIGNAL( clicked(QListViewItem*) ), | 29 | connect( this, SIGNAL( clicked(QListViewItem*) ), |
30 | SLOT( refresh(QListViewItem*) ) ); | 30 | SLOT( refresh(QListViewItem*) ) ); |
31 | connect( this, SIGNAL( returnPressed(QListViewItem*) ), | 31 | connect( this, SIGNAL( returnPressed(QListViewItem*) ), |
32 | SLOT( refresh(QListViewItem*) ) ); | 32 | SLOT( refresh(QListViewItem*) ) ); |
33 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 33 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
34 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 34 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
35 | setSorting(0); | 35 | setSorting(0); |
36 | } | 36 | } |
37 | 37 | ||
38 | AccountView::~AccountView() | 38 | AccountView::~AccountView() |
39 | { | 39 | { |
40 | imapAccounts.clear(); | 40 | imapAccounts.clear(); |
41 | mhAccounts.clear(); | 41 | mhAccounts.clear(); |
42 | } | 42 | } |
43 | 43 | ||
44 | void AccountView::slotContextMenu(int id) | 44 | void AccountView::slotContextMenu(int id) |
45 | { | 45 | { |
46 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 46 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
47 | if (!view) return; | 47 | if (!view) return; |
48 | view->contextMenuSelected(id); | 48 | view->contextMenuSelected(id); |
49 | } | 49 | } |
50 | 50 | ||
51 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 51 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
52 | { | 52 | { |
53 | if (button==1) {return;} | 53 | if (button==1) {return;} |
54 | if (!item) return; | 54 | if (!item) return; |
55 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 55 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
56 | QPopupMenu*m = view->getContextMenu(); | 56 | QPopupMenu*m = view->getContextMenu(); |
57 | if (!m) return; | 57 | if (!m) return; |
58 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 58 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
59 | m->setFocus(); | 59 | m->setFocus(); |
60 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 60 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
61 | delete m; | 61 | delete m; |
62 | } | 62 | } |
63 | 63 | ||
64 | void AccountView::populate( QList<Account> list ) | 64 | void AccountView::populate( QList<Account> list ) |
65 | { | 65 | { |
66 | clear(); | 66 | clear(); |
67 | 67 | ||
68 | imapAccounts.clear(); | 68 | imapAccounts.clear(); |
69 | mhAccounts.clear(); | 69 | mhAccounts.clear(); |
70 | 70 | ||
71 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 71 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
72 | 72 | ||
73 | Account *it; | 73 | Account *it; |
74 | for ( it = list.first(); it; it = list.next() ) | 74 | for ( it = list.first(); it; it = list.next() ) |
75 | { | 75 | { |
76 | if ( it->getType() == MAILLIB::A_IMAP ) | 76 | if ( it->getType() == MAILLIB::A_IMAP ) |
77 | { | 77 | { |
78 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 78 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
79 | imapAccounts.append(new IMAPviewItem( imap, this )); | 79 | imapAccounts.append(new IMAPviewItem( imap, this )); |
80 | } | 80 | } |
81 | else if ( it->getType() == MAILLIB::A_POP3 ) | 81 | else if ( it->getType() == MAILLIB::A_POP3 ) |
82 | { | 82 | { |
83 | POP3account *pop3 = static_cast<POP3account *>(it); | 83 | POP3account *pop3 = static_cast<POP3account *>(it); |
84 | /* must not be hold 'cause it isn't required */ | 84 | /* must not be hold 'cause it isn't required */ |
85 | (void) new POP3viewItem( pop3, this ); | 85 | (void) new POP3viewItem( pop3, this ); |
86 | } | 86 | } |
87 | else if ( it->getType() == MAILLIB::A_NNTP ) | 87 | else if ( it->getType() == MAILLIB::A_NNTP ) |
88 | { | 88 | { |
89 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 89 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
90 | /* must not be hold 'cause it isn't required */ | 90 | /* must not be hold 'cause it isn't required */ |
91 | (void) new NNTPviewItem( nntp, this ); | 91 | (void) new NNTPviewItem( nntp, this ); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void AccountView::refresh(QListViewItem *item) | 96 | void AccountView::refresh(QListViewItem *item) |
97 | { | 97 | { |
98 | if ( item ) | 98 | if ( item ) |
99 | { | 99 | { |
100 | int result = KMessageBox::warningContinueCancel(this, | 100 | bool ask = true; |
101 | qDebug("text -%s- ",item->text( 0 ).latin1() ); | ||
102 | if ( item->text( 0 ) == i18n (" Local Mailfolders") ) | ||
103 | ask = false; | ||
104 | else { | ||
105 | if ( item->parent() ) | ||
106 | if ( item->parent()->text( 0 ) == i18n (" Local Mailfolders") ) | ||
107 | ask = false; | ||
108 | } | ||
109 | if ( ask ) { | ||
110 | int result = KMessageBox::warningContinueCancel(this, | ||
101 | i18n("Refresh\n%1\n?").arg( item->text(0) ), | 111 | i18n("Refresh\n%1\n?").arg( item->text(0) ), |
102 | i18n("Refresh"),i18n("Refresh"),i18n("Cancel"), | 112 | i18n("Refresh"),i18n("Refresh"),i18n("Cancel"), |
103 | true); | 113 | true); |
104 | if (result != KMessageBox::Continue) return; | 114 | if (result != KMessageBox::Continue) return; |
115 | } | ||
105 | m_currentItem = item; | 116 | m_currentItem = item; |
106 | topLevelWidget()->setCaption( i18n ( "Refreshing %1 ... please wait" ). arg ( m_currentItem->text( 0 ) ) ) ; | 117 | topLevelWidget()->setCaption( i18n ( "Refreshing %1 ... please wait" ). arg ( m_currentItem->text( 0 ) ) ) ; |
107 | QTimer::singleShot( 500, this, SLOT ( refreshCurrentSelected() ) ); | 118 | QTimer::singleShot( 500, this, SLOT ( refreshCurrentSelected() ) ); |
108 | 119 | ||
109 | } | 120 | } |
110 | } | 121 | } |
111 | void AccountView::refreshOutgoing() | 122 | void AccountView::refreshOutgoing() |
112 | { | 123 | { |
113 | m_currentItem = currentItem(); | 124 | m_currentItem = currentItem(); |
114 | if ( !m_currentItem ) return; | 125 | if ( !m_currentItem ) return; |
115 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 126 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
116 | if ( !view->getFolder() ) | 127 | if ( !view->getFolder() ) |
117 | return; | 128 | return; |
118 | QString bName = view->getFolder()->getDisplayName(); | 129 | QString bName = view->getFolder()->getDisplayName(); |
119 | if (bName.startsWith("/")&&bName.length()>1) | 130 | if (bName.startsWith("/")&&bName.length()>1) |
120 | { | 131 | { |
121 | bName.replace(0,1,""); | 132 | bName.replace(0,1,""); |
122 | } | 133 | } |
123 | int pos = bName.findRev("/"); | 134 | int pos = bName.findRev("/"); |
124 | if (pos > 0) | 135 | if (pos > 0) |
125 | { | 136 | { |
126 | bName.replace(0,pos+1,""); | 137 | bName.replace(0,pos+1,""); |
127 | } | 138 | } |
128 | //qDebug("name *%s* ",bName.lower().latin1() ); | 139 | //qDebug("name *%s* ",bName.lower().latin1() ); |
129 | if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) { | 140 | if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) { |
130 | refreshCurrent(); | 141 | refreshCurrent(); |
131 | // qDebug("refresh "); | 142 | // qDebug("refresh "); |
132 | } | 143 | } |
133 | } | 144 | } |
134 | void AccountView::refreshCurrentSelected() | 145 | void AccountView::refreshCurrentSelected() |
135 | { | 146 | { |
136 | if ( !m_currentItem ) return; | 147 | if ( !m_currentItem ) return; |
137 | QValueList<RecMailP> headerlist; | 148 | QValueList<RecMailP> headerlist; |
138 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 149 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
139 | view->refresh(headerlist); | 150 | view->refresh(headerlist); |
140 | emit refreshMailview(headerlist); | 151 | emit refreshMailview(headerlist); |
141 | topLevelWidget()->setCaption( i18n ( "KOpieMail/Pi" ) ) ; | 152 | topLevelWidget()->setCaption( i18n ( "KOpieMail/Pi" ) ) ; |
142 | } | 153 | } |
143 | 154 | ||
144 | void AccountView::refreshCurrent() | 155 | void AccountView::refreshCurrent() |
145 | { | 156 | { |
146 | m_currentItem = currentItem(); | 157 | m_currentItem = currentItem(); |
147 | if ( !m_currentItem ) return; | 158 | if ( !m_currentItem ) return; |
148 | topLevelWidget()->setCaption( i18n ( "Refreshing %1 ... please wait" ). arg ( m_currentItem->text( 0 ) ) ) ; | 159 | topLevelWidget()->setCaption( i18n ( "Refreshing %1 ... please wait" ). arg ( m_currentItem->text( 0 ) ) ) ; |
149 | QTimer::singleShot( 500, this, SLOT ( refreshCurrentSelected() ) ); | 160 | QTimer::singleShot( 500, this, SLOT ( refreshCurrentSelected() ) ); |
150 | } | 161 | } |
151 | 162 | ||
152 | void AccountView::refreshAll() | 163 | void AccountView::refreshAll() |
153 | { | 164 | { |
154 | } | 165 | } |
155 | 166 | ||
156 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 167 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
157 | { | 168 | { |
158 | QListViewItem*item = selectedItem (); | 169 | QListViewItem*item = selectedItem (); |
159 | if (!item) return new RecBody(); | 170 | if (!item) return new RecBody(); |
160 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 171 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
161 | return view->fetchBody(aMail); | 172 | return view->fetchBody(aMail); |
162 | } | 173 | } |
163 | 174 | ||
164 | void AccountView::setupFolderselect(Selectstore*sels) | 175 | void AccountView::setupFolderselect(Selectstore*sels) |
165 | { | 176 | { |
166 | 177 | ||
167 | #ifndef DESKTOP_VERSION | 178 | #ifndef DESKTOP_VERSION |
168 | sels->showMaximized(); | 179 | sels->showMaximized(); |
169 | #else | 180 | #else |
170 | sels->show(); | 181 | sels->show(); |
171 | #endif | 182 | #endif |
172 | QStringList sFolders; | 183 | QStringList sFolders; |
173 | unsigned int i = 0; | 184 | unsigned int i = 0; |
174 | for (i=0; i < mhAccounts.count();++i) | 185 | for (i=0; i < mhAccounts.count();++i) |
175 | { | 186 | { |
176 | mhAccounts[i]->refresh(false); | 187 | mhAccounts[i]->refresh(false); |
177 | sFolders = mhAccounts[i]->subFolders(); | 188 | sFolders = mhAccounts[i]->subFolders(); |
178 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 189 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
179 | } | 190 | } |
180 | for (i=0; i < imapAccounts.count();++i) | 191 | for (i=0; i < imapAccounts.count();++i) |
181 | { | 192 | { |
182 | if (imapAccounts[i]->offline()) | 193 | if (imapAccounts[i]->offline()) |
183 | continue; | 194 | continue; |
184 | imapAccounts[i]->refreshFolders(false); | 195 | imapAccounts[i]->refreshFolders(false); |
185 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 196 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
186 | } | 197 | } |
187 | } | 198 | } |
188 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) | 199 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) |
189 | { | 200 | { |
190 | #if 0 | 201 | #if 0 |
191 | AbstractMail*targetMail = 0; | 202 | AbstractMail*targetMail = 0; |
192 | QString targetFolder = ""; | 203 | QString targetFolder = ""; |
193 | Selectstore sels; | 204 | Selectstore sels; |
194 | setupFolderselect(&sels); | 205 | setupFolderselect(&sels); |
195 | if (!sels.exec()) return; | 206 | if (!sels.exec()) return; |
196 | targetMail = sels.currentMail(); | 207 | targetMail = sels.currentMail(); |
197 | targetFolder = sels.currentFolder(); | 208 | targetFolder = sels.currentFolder(); |
198 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 209 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
199 | targetFolder.isEmpty()) | 210 | targetFolder.isEmpty()) |
200 | { | 211 | { |
201 | return; | 212 | return; |
202 | } | 213 | } |
203 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 214 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
204 | { | 215 | { |
205 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 216 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
206 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 217 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
207 | return; | 218 | return; |
208 | } | 219 | } |
209 | int maxsize = 0; | 220 | int maxsize = 0; |
210 | if ( sels.useSize->isChecked()) | 221 | if ( sels.useSize->isChecked()) |
211 | maxsize = sels.sizeSpinBox->value(); | 222 | maxsize = sels.sizeSpinBox->value(); |
212 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 223 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
213 | #endif | 224 | #endif |
214 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); | 225 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); |
215 | refreshCurrent(); | 226 | refreshCurrent(); |
216 | 227 | ||
217 | } | 228 | } |
218 | 229 | ||
219 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 230 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
220 | { | 231 | { |
221 | AbstractMail*targetMail = 0; | 232 | AbstractMail*targetMail = 0; |
222 | QString targetFolder = ""; | 233 | QString targetFolder = ""; |
223 | Selectstore sels; | 234 | Selectstore sels; |
224 | setupFolderselect(&sels); | 235 | setupFolderselect(&sels); |
225 | if (!sels.exec()) return; | 236 | if (!sels.exec()) return; |
226 | targetMail = sels.currentMail(); | 237 | targetMail = sels.currentMail(); |
227 | targetFolder = sels.currentFolder(); | 238 | targetFolder = sels.currentFolder(); |
228 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 239 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
229 | targetFolder.isEmpty()) | 240 | targetFolder.isEmpty()) |
230 | { | 241 | { |
231 | return; | 242 | return; |
232 | } | 243 | } |
233 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 244 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
234 | { | 245 | { |
235 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 246 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
236 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 247 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
237 | return; | 248 | return; |
238 | } | 249 | } |
239 | int maxsize = 0; | 250 | int maxsize = 0; |
240 | if ( sels.useSize->isChecked()) | 251 | if ( sels.useSize->isChecked()) |
241 | maxsize = sels.sizeSpinBox->value(); | 252 | maxsize = sels.sizeSpinBox->value(); |
242 | 253 | ||
243 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 254 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
244 | refreshCurrent(); | 255 | refreshCurrent(); |
245 | } | 256 | } |
246 | 257 | ||
247 | bool AccountView::currentisDraft() | 258 | bool AccountView::currentisDraft() |
248 | { | 259 | { |
249 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 260 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
250 | if (!view) return false; | 261 | if (!view) return false; |
251 | return view->isDraftfolder(); | 262 | return view->isDraftfolder(); |
252 | } | 263 | } |