| 128 | } |
| 129 | |
| 130 | bool PerforceImportMetadataWidget::validateP4user(const QString& projectDir) const |
| 131 | { |
| 132 | QProcess exec; |
| 133 | QProcessEnvironment p4execEnvironment; |
| 134 | p4execEnvironment.insert(QStringLiteral("P4PORT"), m_ui->p4portEdit->displayText()); |
| 135 | exec.setWorkingDirectory(projectDir); |
| 136 | exec.setProcessEnvironment(p4execEnvironment); |
| 137 | exec.start(m_ui->executableLoc->url().toLocalFile(), QStringList{QStringLiteral("workspaces"), |
| 138 | QStringLiteral("-u"), m_ui->p4userEdit->text()} |
| 139 | ); |
| 140 | exec.waitForFinished(); |
| 141 | |
| 142 | const auto processStdout = QString::fromUtf8(exec.readAllStandardOutput()); |
| 143 | const auto processStderr = QString::fromUtf8(exec.readAllStandardError()); |
| 144 | |
| 145 | // std::cout << "Exited with code: " << exec.exitCode() << std::endl; |
| 146 | // std::cout << "Exited with stdout" << processStdout.toStdString() << std::endl; |
| 147 | // std::cout << "Exited with stderr" << processStderr.toStdString() << std::endl; |
| 148 | if (exec.exitCode() != 0) { |
| 149 | if(!processStderr.isEmpty()) { |
| 150 | m_ui->errorMsg->setText(processStderr); |
| 151 | } else { |
| 152 | m_ui->errorMsg->setText(i18n("P4 Client failed with exit code: %1", exec.exitCode())); |
| 153 | } |
| 154 | return false; |
| 155 | } |
| 156 | if(!processStdout.isEmpty()) { |
| 157 | const auto clientCmdOutput = QStringView{processStdout}.split(QLatin1Char('\n'), Qt::SkipEmptyParts); |
| 158 | QStringList clientItems; |
| 159 | clientItems.reserve(clientCmdOutput.size()); |
| 160 | for (const auto clientLine : clientCmdOutput) { |
| 161 | const auto wordsInLine = clientLine.split(QLatin1Char(' ')); |
| 162 | // Client mvo_testkdevinteg 2017/05/22 root C:\P4repo 'Created by mvo. ' -- Line would be expected to look like so |
| 163 | clientItems.append(wordsInLine.at(1).toString()); |
| 164 | } |
| 165 | m_ui->p4clientEdit->addItems(clientItems); |
| 166 | } |
| 167 | return true; |
| 168 | } |
| 169 | |
| 170 | bool PerforceImportMetadataWidget::validateP4port(const QString& projectDir) const |
| 171 | { |
nothing calls this directly
no test coverage detected