author | zautrix <zautrix> | 2005-03-26 17:26:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-26 17:26:28 (UTC) |
commit | 36dd498ad2f5a2cf43fc08c621669fe42198e5eb (patch) (unidiff) | |
tree | 78f826bd02a35e0624d245f267ec5b595350574e | |
parent | e3f00322eb77bd03250eb66a2574b640de9aebb4 (diff) | |
download | kdepimpi-36dd498ad2f5a2cf43fc08c621669fe42198e5eb.zip kdepimpi-36dd498ad2f5a2cf43fc08c621669fe42198e5eb.tar.gz kdepimpi-36dd498ad2f5a2cf43fc08c621669fe42198e5eb.tar.bz2 |
fix
-rw-r--r-- | kmicromail/accountview.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index e9be224..6227f6d 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp | |||
@@ -10,192 +10,194 @@ | |||
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 <qspinbox.h> | 18 | #include <qspinbox.h> |
19 | #include <klocale.h> | 19 | #include <klocale.h> |
20 | 20 | ||
21 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
22 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 22 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
23 | : QListView( parent, name, flags ) | 23 | : QListView( parent, name, flags ) |
24 | { | 24 | { |
25 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 25 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
26 | SLOT( refresh(QListViewItem*) ) ); | 26 | SLOT( refresh(QListViewItem*) ) ); |
27 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 27 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
28 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 28 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
29 | setSorting(0); | 29 | setSorting(0); |
30 | } | 30 | } |
31 | 31 | ||
32 | AccountView::~AccountView() | 32 | AccountView::~AccountView() |
33 | { | 33 | { |
34 | imapAccounts.clear(); | 34 | imapAccounts.clear(); |
35 | mhAccounts.clear(); | 35 | mhAccounts.clear(); |
36 | } | 36 | } |
37 | 37 | ||
38 | void AccountView::slotContextMenu(int id) | 38 | void AccountView::slotContextMenu(int id) |
39 | { | 39 | { |
40 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 40 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
41 | if (!view) return; | 41 | if (!view) return; |
42 | view->contextMenuSelected(id); | 42 | view->contextMenuSelected(id); |
43 | } | 43 | } |
44 | 44 | ||
45 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 45 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
46 | { | 46 | { |
47 | if (button==1) {return;} | 47 | if (button==1) {return;} |
48 | if (!item) return; | 48 | if (!item) return; |
49 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 49 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
50 | QPopupMenu*m = view->getContextMenu(); | 50 | QPopupMenu*m = view->getContextMenu(); |
51 | if (!m) return; | 51 | if (!m) return; |
52 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 52 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
53 | m->setFocus(); | 53 | m->setFocus(); |
54 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 54 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
55 | delete m; | 55 | delete m; |
56 | } | 56 | } |
57 | 57 | ||
58 | void AccountView::populate( QList<Account> list ) | 58 | void AccountView::populate( QList<Account> list ) |
59 | { | 59 | { |
60 | clear(); | 60 | clear(); |
61 | 61 | ||
62 | imapAccounts.clear(); | 62 | imapAccounts.clear(); |
63 | mhAccounts.clear(); | 63 | mhAccounts.clear(); |
64 | 64 | ||
65 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 65 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
66 | 66 | ||
67 | Account *it; | 67 | Account *it; |
68 | for ( it = list.first(); it; it = list.next() ) | 68 | for ( it = list.first(); it; it = list.next() ) |
69 | { | 69 | { |
70 | if ( it->getType() == MAILLIB::A_IMAP ) | 70 | if ( it->getType() == MAILLIB::A_IMAP ) |
71 | { | 71 | { |
72 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 72 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
73 | imapAccounts.append(new IMAPviewItem( imap, this )); | 73 | imapAccounts.append(new IMAPviewItem( imap, this )); |
74 | } | 74 | } |
75 | else if ( it->getType() == MAILLIB::A_POP3 ) | 75 | else if ( it->getType() == MAILLIB::A_POP3 ) |
76 | { | 76 | { |
77 | POP3account *pop3 = static_cast<POP3account *>(it); | 77 | POP3account *pop3 = static_cast<POP3account *>(it); |
78 | /* must not be hold 'cause it isn't required */ | 78 | /* must not be hold 'cause it isn't required */ |
79 | (void) new POP3viewItem( pop3, this ); | 79 | (void) new POP3viewItem( pop3, this ); |
80 | } | 80 | } |
81 | else if ( it->getType() == MAILLIB::A_NNTP ) | 81 | else if ( it->getType() == MAILLIB::A_NNTP ) |
82 | { | 82 | { |
83 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 83 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
84 | /* must not be hold 'cause it isn't required */ | 84 | /* must not be hold 'cause it isn't required */ |
85 | (void) new NNTPviewItem( nntp, this ); | 85 | (void) new NNTPviewItem( nntp, this ); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | void AccountView::refresh(QListViewItem *item) | 90 | void AccountView::refresh(QListViewItem *item) |
91 | { | 91 | { |
92 | if ( item ) | 92 | if ( item ) |
93 | { | 93 | { |
94 | m_currentItem = item; | 94 | m_currentItem = item; |
95 | QValueList<RecMailP> headerlist; | 95 | QValueList<RecMailP> headerlist; |
96 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 96 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
97 | view->refresh(headerlist); | 97 | view->refresh(headerlist); |
98 | emit refreshMailview(headerlist); | 98 | emit refreshMailview(headerlist); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | void AccountView::refreshOutgoing() | 101 | void AccountView::refreshOutgoing() |
102 | { | 102 | { |
103 | m_currentItem = currentItem(); | 103 | m_currentItem = currentItem(); |
104 | if ( !m_currentItem ) return; | 104 | if ( !m_currentItem ) return; |
105 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 105 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
106 | if ( !view->getFolder() ) | ||
107 | return; | ||
106 | QString bName = view->getFolder()->getDisplayName(); | 108 | QString bName = view->getFolder()->getDisplayName(); |
107 | if (bName.startsWith("/")&&bName.length()>1) | 109 | if (bName.startsWith("/")&&bName.length()>1) |
108 | { | 110 | { |
109 | bName.replace(0,1,""); | 111 | bName.replace(0,1,""); |
110 | } | 112 | } |
111 | int pos = bName.findRev("/"); | 113 | int pos = bName.findRev("/"); |
112 | if (pos > 0) | 114 | if (pos > 0) |
113 | { | 115 | { |
114 | bName.replace(0,pos+1,""); | 116 | bName.replace(0,pos+1,""); |
115 | } | 117 | } |
116 | //qDebug("name *%s* ",bName.lower().latin1() ); | 118 | //qDebug("name *%s* ",bName.lower().latin1() ); |
117 | if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) { | 119 | if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) { |
118 | refreshCurrent(); | 120 | refreshCurrent(); |
119 | // qDebug("refresh "); | 121 | // qDebug("refresh "); |
120 | } | 122 | } |
121 | } | 123 | } |
122 | 124 | ||
123 | void AccountView::refreshCurrent() | 125 | void AccountView::refreshCurrent() |
124 | { | 126 | { |
125 | m_currentItem = currentItem(); | 127 | m_currentItem = currentItem(); |
126 | if ( !m_currentItem ) return; | 128 | if ( !m_currentItem ) return; |
127 | QValueList<RecMailP> headerlist; | 129 | QValueList<RecMailP> headerlist; |
128 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 130 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
129 | view->refresh(headerlist); | 131 | view->refresh(headerlist); |
130 | emit refreshMailview(headerlist); | 132 | emit refreshMailview(headerlist); |
131 | } | 133 | } |
132 | 134 | ||
133 | void AccountView::refreshAll() | 135 | void AccountView::refreshAll() |
134 | { | 136 | { |
135 | } | 137 | } |
136 | 138 | ||
137 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 139 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
138 | { | 140 | { |
139 | QListViewItem*item = selectedItem (); | 141 | QListViewItem*item = selectedItem (); |
140 | if (!item) return new RecBody(); | 142 | if (!item) return new RecBody(); |
141 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 143 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
142 | return view->fetchBody(aMail); | 144 | return view->fetchBody(aMail); |
143 | } | 145 | } |
144 | 146 | ||
145 | void AccountView::setupFolderselect(Selectstore*sels) | 147 | void AccountView::setupFolderselect(Selectstore*sels) |
146 | { | 148 | { |
147 | 149 | ||
148 | #ifndef DESKTOP_VERSION | 150 | #ifndef DESKTOP_VERSION |
149 | sels->showMaximized(); | 151 | sels->showMaximized(); |
150 | #else | 152 | #else |
151 | sels->show(); | 153 | sels->show(); |
152 | #endif | 154 | #endif |
153 | QStringList sFolders; | 155 | QStringList sFolders; |
154 | unsigned int i = 0; | 156 | unsigned int i = 0; |
155 | for (i=0; i < mhAccounts.count();++i) | 157 | for (i=0; i < mhAccounts.count();++i) |
156 | { | 158 | { |
157 | mhAccounts[i]->refresh(false); | 159 | mhAccounts[i]->refresh(false); |
158 | sFolders = mhAccounts[i]->subFolders(); | 160 | sFolders = mhAccounts[i]->subFolders(); |
159 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 161 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
160 | } | 162 | } |
161 | for (i=0; i < imapAccounts.count();++i) | 163 | for (i=0; i < imapAccounts.count();++i) |
162 | { | 164 | { |
163 | if (imapAccounts[i]->offline()) | 165 | if (imapAccounts[i]->offline()) |
164 | continue; | 166 | continue; |
165 | imapAccounts[i]->refreshFolders(false); | 167 | imapAccounts[i]->refreshFolders(false); |
166 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 168 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
167 | } | 169 | } |
168 | } | 170 | } |
169 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) | 171 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) |
170 | { | 172 | { |
171 | #if 0 | 173 | #if 0 |
172 | AbstractMail*targetMail = 0; | 174 | AbstractMail*targetMail = 0; |
173 | QString targetFolder = ""; | 175 | QString targetFolder = ""; |
174 | Selectstore sels; | 176 | Selectstore sels; |
175 | setupFolderselect(&sels); | 177 | setupFolderselect(&sels); |
176 | if (!sels.exec()) return; | 178 | if (!sels.exec()) return; |
177 | targetMail = sels.currentMail(); | 179 | targetMail = sels.currentMail(); |
178 | targetFolder = sels.currentFolder(); | 180 | targetFolder = sels.currentFolder(); |
179 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 181 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
180 | targetFolder.isEmpty()) | 182 | targetFolder.isEmpty()) |
181 | { | 183 | { |
182 | return; | 184 | return; |
183 | } | 185 | } |
184 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 186 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
185 | { | 187 | { |
186 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 188 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
187 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 189 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
188 | return; | 190 | return; |
189 | } | 191 | } |
190 | int maxsize = 0; | 192 | int maxsize = 0; |
191 | if ( sels.useSize->isChecked()) | 193 | if ( sels.useSize->isChecked()) |
192 | maxsize = sels.sizeSpinBox->value(); | 194 | maxsize = sels.sizeSpinBox->value(); |
193 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 195 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
194 | #endif | 196 | #endif |
195 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); | 197 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); |
196 | refreshCurrent(); | 198 | refreshCurrent(); |
197 | 199 | ||
198 | } | 200 | } |
199 | 201 | ||
200 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 202 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
201 | { | 203 | { |