| 14 | QObject::tr("Key"), QObject::tr("Suggestion"), QObject::tr("FileType")}; |
| 15 | static QStringList kLibItemNames{QObject::tr("FileName"), QObject::tr("Installed"), QObject::tr("Detail")}; |
| 16 | CodePorting::CodePorting(QObject *parent) |
| 17 | : QObject(parent) |
| 18 | { |
| 19 | connect(&process, &QProcess::started, [this]() { |
| 20 | this->updateStatus(kRuning); |
| 21 | QString startMsg = tr("Start execute command: \"%1\" \"%2\" in workspace \"%3\".\n") |
| 22 | .arg(process.program().split("/").last(), process.arguments().join(" "), process.workingDirectory()); |
| 23 | emit outputInformation(startMsg, OutputPane::OutputFormat::NormalMessage); |
| 24 | }); |
| 25 | |
| 26 | connect(&process, &QProcess::readyReadStandardOutput, [&]() { |
| 27 | process.setReadChannel(QProcess::StandardOutput); |
| 28 | while (process.canReadLine()) { |
| 29 | QString line = QString::fromUtf8(process.readLine()); |
| 30 | auto mode = parseFormat(line); |
| 31 | emit outputInformation(line, OutputPane::OutputFormat::StdOut, mode); |
| 32 | } |
| 33 | }); |
| 34 | |
| 35 | connect(&process, &QProcess::readyReadStandardError, [&]() { |
| 36 | process.setReadChannel(QProcess::StandardError); |
| 37 | while (process.canReadLine()) { |
| 38 | QString line = QString::fromUtf8(process.readLine()); |
| 39 | QRegularExpression reg("\\s\\[INFO\\]\\s"); |
| 40 | bool isInfo = reg.match(line).hasMatch(); |
| 41 | OutputPane::OutputFormat format = isInfo ? OutputPane::StdOut : OutputPane::StdErr; |
| 42 | auto mode = parseFormat(line); |
| 43 | emit outputInformation(line, format, mode); |
| 44 | |
| 45 | // The output content include report path, so get it. |
| 46 | QString reportPath = parseReportPath(line); |
| 47 | if (!reportPath.isEmpty()) { |
| 48 | bool bSuccessful = parseReportFromFile(reportPath); |
| 49 | if (bSuccessful) { |
| 50 | emit outputInformation(tr("Parse report successful.\n"), OutputPane::StdOut, mode); |
| 51 | } else { |
| 52 | emit outputInformation(tr("Parse report Failed.\n"), OutputPane::StdErr, mode); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | }); |
| 57 | |
| 58 | connect(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), |
| 59 | [&](int exitcode, QProcess::ExitStatus exitStatus) { |
| 60 | QString retMsg; |
| 61 | OutputPane::OutputFormat format = OutputPane::NormalMessage; |
| 62 | if (0 == exitcode && exitStatus == QProcess::ExitStatus::NormalExit) { |
| 63 | retMsg = tr("The process \"%1\" exited normally.\n").arg(process.program()); |
| 64 | this->updateStatus(kSuccessful); |
| 65 | } else if (exitStatus == QProcess::NormalExit) { |
| 66 | retMsg = tr("The process \"%1\" exited with code %2.\n") |
| 67 | .arg(process.program(), QString::number(exitcode)); |
| 68 | this->updateStatus(kSuccessful); |
| 69 | } else { |
| 70 | retMsg = tr("The process \"%1\" crashed.\n") |
| 71 | .arg(process.program()); |
| 72 | format = OutputPane::ErrorMessage; |
| 73 | this->updateStatus(kFailed); |
nothing calls this directly
no test coverage detected