1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef WORDCOUNTANALYSE_H |
6 | #define WORDCOUNTANALYSE_H |
7 | |
8 | #include <QProcess> |
9 | |
10 | struct ActionAnalyseArgs |
11 | { |
12 | QString workspace; |
13 | QString language; |
14 | QString storage; |
15 | ActionAnalyseArgs(); |
16 | ActionAnalyseArgs(const QString &workspace, const QString &language, const QString &storage); |
17 | ActionAnalyseArgs(const ActionAnalyseArgs &as); |
18 | ActionAnalyseArgs &operator=(const ActionAnalyseArgs &as); |
19 | }; |
20 | |
21 | class WordCountAnalyse : public QProcess |
22 | { |
23 | Q_OBJECT |
24 | public: |
25 | explicit WordCountAnalyse(QObject *parent = nullptr); |
26 | |
27 | void setArgs(const ActionAnalyseArgs& args); |
28 | ActionAnalyseArgs args() const; |
29 | QString getStorage() const; |
30 | QString getWorkspace() const; |
31 | QString getLanguage() const; |
32 | |
33 | void start(); |
34 | |
35 | private: |
36 | QString getPythonVersion(); |
37 | |
38 | void setStorage(const QString &storage); |
39 | void setWorkspace(const QString &workspace); |
40 | void setLanguage(const QString &language); |
41 | |
42 | signals: |
43 | void analyseDone(bool result); |
44 | |
45 | private slots: |
46 | void errorOccurred(QProcess::ProcessError err); |
47 | void finished(int exitCode, QProcess::ExitStatus status); |
48 | |
49 | private: |
50 | ActionAnalyseArgs processArgs; |
51 | QString pythonVersion; |
52 | }; |
53 | |
54 | #endif // WORDCOUNTANALYSE_H |
55 |