| 127 | } |
| 128 | |
| 129 | void MainWindow::load(QTextStream &textStream) |
| 130 | { |
| 131 | bool local = false; |
| 132 | QString url; |
| 133 | QString errorMessage; |
| 134 | QStringList versions; |
| 135 | mAllErrors.clear(); |
| 136 | while (true) { |
| 137 | QString line = textStream.readLine(); |
| 138 | if (line.isNull()) |
| 139 | break; |
| 140 | if (line.startsWith("ftp://") || line.startsWith("https://") || (line.startsWith(DACA2_PACKAGES) && line.endsWith(".tar.xz"))) { |
| 141 | local = line.startsWith(DACA2_PACKAGES) && line.endsWith(".tar.xz"); |
| 142 | url = line; |
| 143 | if (!errorMessage.isEmpty()) |
| 144 | mAllErrors << errorMessage; |
| 145 | errorMessage.clear(); |
| 146 | } else if (!url.isEmpty()) { |
| 147 | static const QRegularExpression severityRe("^.*: (error|warning|style|note):.*$"); |
| 148 | if (!severityRe.match(line).hasMatch()) |
| 149 | continue; |
| 150 | if (!local) { |
| 151 | const QRegularExpressionMatch matchRes = mVersionRe.match(line); |
| 152 | if (matchRes.hasMatch()) { |
| 153 | const QString version = matchRes.captured(1); |
| 154 | if (versions.indexOf(version) < 0) |
| 155 | versions << version; |
| 156 | } |
| 157 | } |
| 158 | if (line.indexOf(": note:") > 0) |
| 159 | errorMessage += '\n' + line; |
| 160 | else if (errorMessage.isEmpty()) { |
| 161 | errorMessage = url + '\n' + line; |
| 162 | } else { |
| 163 | mAllErrors << errorMessage; |
| 164 | errorMessage = url + '\n' + line; |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | if (!errorMessage.isEmpty()) |
| 169 | mAllErrors << errorMessage; |
| 170 | |
| 171 | ui->version->clear(); |
| 172 | if (versions.size() > 1) |
| 173 | ui->version->addItem(""); |
| 174 | ui->version->addItems(versions); |
| 175 | |
| 176 | filter(""); |
| 177 | } |
| 178 | |
| 179 | void MainWindow::refreshResults() |
| 180 | { |