-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWebserviceWindow.hh
94 lines (72 loc) · 2.09 KB
/
WebserviceWindow.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef WEBSERVICEWINDOW_H
#define WEBSERVICEWINDOW_H
#include <QNetworkReply>
#include <QWidget>
#include <QSharedPointer>
#include <QString>
namespace Ui {
class WebserviceWindow;
}
namespace alpinocorpus {
class CorpusWriter;
}
class QNetworkAccessManager;
class QProgressDialog;
class WebserviceWindow : public QWidget {
Q_OBJECT
public:
WebserviceWindow(QWidget *parent = 0, Qt::WindowFlags f = 0);
~WebserviceWindow();
signals:
void parseSentencesFinished(QString corpus);
/*!
* This signal is emitted when there is progress (one or more sentences
* were parse.
*/
void progress();
private slots:
/*!
* Ask the user which plain text file(s) to load into the sentences text field.
*/
void openSentencesFile();
/*!
* Ask the user where to save the parsed sentences and send the sentences
* to the webservice.
*/
void parseSentences();
/*!
* Read available response data from the request reply (i.e. the xml of a parsed sentence)
*/
void readResponse();
/*!
* Called when receiving of response is finished (or errored or aborted).
*/
void finishResponse();
/*!
* Display a message that an error occurred during downloading of the response from the webservice.
*/
void errorResponse(QNetworkReply::NetworkError error);
/*!
* Called when the parse sentences progress was cancelled by the user.
*/
void cancelResponse();
/*!
* Called when there is progress to report.
*/
void updateProgressDialog();
private:
QSharedPointer<Ui::WebserviceWindow> d_ui;
QSharedPointer<QNetworkAccessManager> d_accessManager;
QProgressDialog *d_progressDialog;
QNetworkReply *d_reply;
QByteArray d_buffer;
int d_numberOfSentences;
int d_numberOfSentencesReceived;
QSharedPointer<alpinocorpus::CorpusWriter> d_corpus;
QString d_corpusFilename;
void clearSentencesField();
void loadSentencesFile(QString const &filename);
int countSentences(QString const &);
void receiveSentence(QString const &);
};
#endif