summaryrefslogtreecommitdiffabout
path: root/kmicromail/accountview.cpp
Unidiff
Diffstat (limited to 'kmicromail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountview.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp
index c9c4a0f..3ad3e9b 100644
--- a/kmicromail/accountview.cpp
+++ b/kmicromail/accountview.cpp
@@ -37,128 +37,146 @@ AccountView::~AccountView()
37 37
38void AccountView::slotContextMenu(int id) 38void 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
45void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 45void 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
58void AccountView::populate( QList<Account> list ) 58void 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
90void AccountView::refresh(QListViewItem *item) 90void 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}
101void AccountView::refreshOutgoing()
102{
103 m_currentItem = currentItem();
104 if ( !m_currentItem ) return;
105 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
106 QString bName = view->getFolder()->getDisplayName();
107 if (bName.startsWith("/")&&bName.length()>1)
108 {
109 bName.replace(0,1,"");
110 }
111 int pos = bName.findRev("/");
112 if (pos > 0)
113 {
114 bName.replace(0,pos+1,"");
115 }
116 if ( bName.lower() == "outgoing" )
117 refreshCurrent();
118}
101 119
102void AccountView::refreshCurrent() 120void AccountView::refreshCurrent()
103{ 121{
104 m_currentItem = currentItem(); 122 m_currentItem = currentItem();
105 if ( !m_currentItem ) return; 123 if ( !m_currentItem ) return;
106 QValueList<RecMailP> headerlist; 124 QValueList<RecMailP> headerlist;
107 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 125 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
108 view->refresh(headerlist); 126 view->refresh(headerlist);
109 emit refreshMailview(headerlist); 127 emit refreshMailview(headerlist);
110} 128}
111 129
112void AccountView::refreshAll() 130void AccountView::refreshAll()
113{ 131{
114} 132}
115 133
116RecBodyP AccountView::fetchBody(const RecMailP&aMail) 134RecBodyP AccountView::fetchBody(const RecMailP&aMail)
117{ 135{
118 QListViewItem*item = selectedItem (); 136 QListViewItem*item = selectedItem ();
119 if (!item) return new RecBody(); 137 if (!item) return new RecBody();
120 AccountViewItem *view = static_cast<AccountViewItem *>(item); 138 AccountViewItem *view = static_cast<AccountViewItem *>(item);
121 return view->fetchBody(aMail); 139 return view->fetchBody(aMail);
122} 140}
123 141
124void AccountView::setupFolderselect(Selectstore*sels) 142void AccountView::setupFolderselect(Selectstore*sels)
125{ 143{
126 144
127#ifndef DESKTOP_VERSION 145#ifndef DESKTOP_VERSION
128 sels->showMaximized(); 146 sels->showMaximized();
129#else 147#else
130 sels->show(); 148 sels->show();
131#endif 149#endif
132 QStringList sFolders; 150 QStringList sFolders;
133 unsigned int i = 0; 151 unsigned int i = 0;
134 for (i=0; i < mhAccounts.count();++i) 152 for (i=0; i < mhAccounts.count();++i)
135 { 153 {
136 mhAccounts[i]->refresh(false); 154 mhAccounts[i]->refresh(false);
137 sFolders = mhAccounts[i]->subFolders(); 155 sFolders = mhAccounts[i]->subFolders();
138 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 156 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
139 } 157 }
140 for (i=0; i < imapAccounts.count();++i) 158 for (i=0; i < imapAccounts.count();++i)
141 { 159 {
142 if (imapAccounts[i]->offline()) 160 if (imapAccounts[i]->offline())
143 continue; 161 continue;
144 imapAccounts[i]->refreshFolders(false); 162 imapAccounts[i]->refreshFolders(false);
145 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 163 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
146 } 164 }
147} 165}
148void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) 166void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper)
149{ 167{
150#if 0 168#if 0
151 AbstractMail*targetMail = 0; 169 AbstractMail*targetMail = 0;
152 QString targetFolder = ""; 170 QString targetFolder = "";
153 Selectstore sels; 171 Selectstore sels;
154 setupFolderselect(&sels); 172 setupFolderselect(&sels);
155 if (!sels.exec()) return; 173 if (!sels.exec()) return;
156 targetMail = sels.currentMail(); 174 targetMail = sels.currentMail();
157 targetFolder = sels.currentFolder(); 175 targetFolder = sels.currentFolder();
158 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 176 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
159 targetFolder.isEmpty()) 177 targetFolder.isEmpty())
160 { 178 {
161 return; 179 return;
162 } 180 }
163 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 181 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
164 { 182 {