summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/searchdiag.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/mail2/searchdiag.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/searchdiag.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/unsupported/mail2/searchdiag.cpp b/noncore/unsupported/mail2/searchdiag.cpp
index 907f6ff..6fb4e4d 100644
--- a/noncore/unsupported/mail2/searchdiag.cpp
+++ b/noncore/unsupported/mail2/searchdiag.cpp
@@ -7,122 +7,122 @@
7 7
8#include "imaphandler.h" 8#include "imaphandler.h"
9#include "searchdiag.h" 9#include "searchdiag.h"
10#include "viewmail.h" 10#include "viewmail.h"
11 11
12 #define INMENU_BODY0 12 #define INMENU_BODY0
13 #define INMENU_HEADERF1 13 #define INMENU_HEADERF1
14 #define INMENU_SUBJECT2 14 #define INMENU_SUBJECT2
15 #define INMENU_FROM3 15 #define INMENU_FROM3
16 #define INMENU_TO4 16 #define INMENU_TO4
17 17
18SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl) 18SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl)
19 : SearchDiagBase(parent, name, fl) 19 : SearchDiagBase(parent, name, fl)
20 { 20 {
21 _selected = false; 21 _selected = false;
22 22
23 in->insertItem(tr("Body"), INMENU_BODY); 23 in->insertItem(tr("Body"), INMENU_BODY);
24 in->insertItem(tr("Header Field"), INMENU_HEADERF); 24 in->insertItem(tr("Header Field"), INMENU_HEADERF);
25 in->insertItem(tr("Subject"), INMENU_SUBJECT); 25 in->insertItem(tr("Subject"), INMENU_SUBJECT);
26 in->insertItem(tr("From"), INMENU_FROM); 26 in->insertItem(tr("From"), INMENU_FROM);
27 in->insertItem(tr("To"), INMENU_TO); 27 in->insertItem(tr("To"), INMENU_TO);
28 28
29 connect(folderView, SIGNAL(folderSelected(Folder)), SLOT(folderSelected(Folder))); 29 connect(folderView, SIGNAL(folderSelected(Folder)), SLOT(folderSelected(Folder)));
30 connect(in, SIGNAL(activated(int)), SLOT(slotInItemActivated(int))); 30 connect(in, SIGNAL(activated(int)), SLOT(slotInItemActivated(int)));
31 connect(mailTable, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(slotMailClicked(IMAPResponseFETCH, IMAPHandler *))); 31 connect(mailTable, SIGNAL(mailClicked(IMAPResponseFETCH,IMAPHandler*)), SLOT(slotMailClicked(IMAPResponseFETCH,IMAPHandler*)));
32} 32}
33 33
34void SearchDiag::accept() 34void SearchDiag::accept()
35{ 35{
36 if (searchFor->text().isEmpty()) { 36 if (searchFor->text().isEmpty()) {
37 QMessageBox::information(this, tr("Error"), tr("<p>Please enter what to search for.</p>"), tr("Ok")); 37 QMessageBox::information(this, tr("Error"), tr("<p>Please enter what to search for.</p>"), tr("Ok"));
38 return; 38 return;
39 } 39 }
40 40
41 if (!_selected) { 41 if (!_selected) {
42 QMessageBox::information(this, tr("Error"), tr("<p>Please select a folder.</p>"), tr("Ok")); 42 QMessageBox::information(this, tr("Error"), tr("<p>Please select a folder.</p>"), tr("Ok"));
43 return; 43 return;
44 } 44 }
45 45
46 if (in->currentItem() == INMENU_HEADERF && other->currentText().isEmpty()) { 46 if (in->currentItem() == INMENU_HEADERF && other->currentText().isEmpty()) {
47 QMessageBox::information(this, tr("Error"), tr("<p>Please enter a header field to search in.</p>"), tr("Ok")); 47 QMessageBox::information(this, tr("Error"), tr("<p>Please enter a header field to search in.</p>"), tr("Ok"));
48 return; 48 return;
49 } 49 }
50 50
51 _folder.topFolder().handler()->iSelect(_folder.fullName()); 51 _folder.topFolder().handler()->iSelect(_folder.fullName());
52 connect(_folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &))); 52 connect(_folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPSelect(IMAPResponse&)));
53} 53}
54 54
55void SearchDiag::folderSelected(Folder folder) 55void SearchDiag::folderSelected(Folder folder)
56{ 56{
57 _selected = true; 57 _selected = true;
58 _folder = folder; 58 _folder = folder;
59} 59}
60 60
61void SearchDiag::slotIMAPSelect(IMAPResponse &response) 61void SearchDiag::slotIMAPSelect(IMAPResponse &response)
62{ 62{
63 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &))); 63 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPSelect(IMAPResponse&)));
64 64
65 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 65 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
66 if (in->currentItem() == INMENU_BODY) { 66 if (in->currentItem() == INMENU_BODY) {
67 response.imapHandler()->iSearch("BODY \"" + searchFor->text() + "\""); 67 response.imapHandler()->iSearch("BODY \"" + searchFor->text() + "\"");
68 } else if (in->currentItem() == INMENU_HEADERF) { 68 } else if (in->currentItem() == INMENU_HEADERF) {
69 response.imapHandler()->iSearch("HEADER \""+ other->currentText() + "\" \"" + searchFor->text() + "\""); 69 response.imapHandler()->iSearch("HEADER \""+ other->currentText() + "\" \"" + searchFor->text() + "\"");
70 } else if (in->currentItem() == INMENU_SUBJECT) { 70 } else if (in->currentItem() == INMENU_SUBJECT) {
71 response.imapHandler()->iSearch("SUBJECT \"" + searchFor->text() + "\""); 71 response.imapHandler()->iSearch("SUBJECT \"" + searchFor->text() + "\"");
72 } else if (in->currentItem() == INMENU_FROM) { 72 } else if (in->currentItem() == INMENU_FROM) {
73 response.imapHandler()->iSearch("FROM \"" + searchFor->text() + "\""); 73 response.imapHandler()->iSearch("FROM \"" + searchFor->text() + "\"");
74 } else if (in->currentItem() == INMENU_TO) { 74 } else if (in->currentItem() == INMENU_TO) {
75 response.imapHandler()->iSearch("TO \"" + searchFor->text() + "\""); 75 response.imapHandler()->iSearch("TO \"" + searchFor->text() + "\"");
76 } else return; 76 } else return;
77 77
78 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSearch(IMAPResponse &))); 78 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPSearch(IMAPResponse&)));
79 } else { 79 } else {
80 QMessageBox::warning(this, tr("Error"), tr("<p>Could not select the folder. Aborting. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); 80 QMessageBox::warning(this, tr("Error"), tr("<p>Could not select the folder. Aborting. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok"));
81 } 81 }
82} 82}
83 83
84void SearchDiag::slotIMAPSearch(IMAPResponse &response) 84void SearchDiag::slotIMAPSearch(IMAPResponse &response)
85{ 85{
86 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); 86 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPSearch(IMAPResponse&)));
87 87
88 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 88 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
89 IMAPResponseSEARCH results = response.SEARCH()[0]; 89 IMAPResponseSEARCH results = response.SEARCH()[0];
90 if (results.mails().count() == 0) { 90 if (results.mails().count() == 0) {
91 QMessageBox::information(this, tr("Results"), tr("<p>No mails match your criteria.</p>"), tr("Ok")); 91 QMessageBox::information(this, tr("Results"), tr("<p>No mails match your criteria.</p>"), tr("Ok"));
92 return; 92 return;
93 } 93 }
94 94
95 response.imapHandler()->iFetch(results.mails().join(","), "ENVELOPE FLAGS UID"); 95 response.imapHandler()->iFetch(results.mails().join(","), "ENVELOPE FLAGS UID");
96 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); 96 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPFetch(IMAPResponse&)));
97 } else { 97 } else {
98 QMessageBox::warning(this, tr("Error"), tr("<p>Search failed. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); 98 QMessageBox::warning(this, tr("Error"), tr("<p>Search failed. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok"));
99 } 99 }
100} 100}
101 101
102void SearchDiag::slotIMAPFetch(IMAPResponse &response) 102void SearchDiag::slotIMAPFetch(IMAPResponse &response)
103{ 103{
104 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); 104 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPSearch(IMAPResponse&)));
105 105
106 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 106 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
107 mailTable->setHeaders(response.FETCH()); 107 mailTable->setHeaders(response.FETCH());
108 } else { 108 } else {
109 QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment())); 109 QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment()));
110 } 110 }
111} 111}
112 112
113void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) 113void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *)
114{ 114{
115 ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true); 115 ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true);
116 viewMail.showMaximized(); 116 viewMail.showMaximized();
117 viewMail.exec(); 117 viewMail.exec();
118} 118}
119 119
120void SearchDiag::slotInItemActivated(int index) 120void SearchDiag::slotInItemActivated(int index)
121{ 121{
122 if (index == INMENU_HEADERF) { 122 if (index == INMENU_HEADERF) {
123 other->setEnabled(true); 123 other->setEnabled(true);
124 } else { 124 } else {
125 other->setEnabled(false); 125 other->setEnabled(false);
126 } 126 }
127} 127}
128 128