ProjectExplorer: Avoid need to fix up portsgatherer command lines

... by creating them with the right device to start with.

Change-Id: Ib2f0f10b67322fe66a609287a629d3d720d83c93
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-05-10 12:53:27 +02:00
parent da0f0ac523
commit 7f2288d9cc
11 changed files with 139 additions and 164 deletions

View File

@@ -106,29 +106,6 @@ void QnxProcessImpl::sendControlSignal(Utils::ControlSignal controlSignal)
const char QnxVersionKey[] = "QnxVersion";
class QnxPortsGatheringMethod : public PortsGatheringMethod
{
// TODO: The command is probably needlessly complicated because the parsing method
// used to be fixed. These two can now be matched to each other.
CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const override
{
Q_UNUSED(protocol)
return {"netstat", {"-na"}};
}
QList<Port> usedPorts(const QByteArray &output) const override
{
QList<Utils::Port> ports;
const QList<QByteArray> lines = output.split('\n');
for (const QByteArray &line : lines) {
const Port port(Utils::parseUsedPortFromNetstatOutput(line));
if (port.isValid() && !ports.contains(port))
ports.append(port);
}
return ports;
}
};
QnxDevice::QnxDevice()
{
setDisplayType(tr("QNX"));
@@ -181,9 +158,27 @@ QVariantMap QnxDevice::toMap() const
return map;
}
PortsGatheringMethod::Ptr QnxDevice::portsGatheringMethod() const
PortsGatheringMethod QnxDevice::portsGatheringMethod() const
{
return PortsGatheringMethod::Ptr(new QnxPortsGatheringMethod);
return {
// TODO: The command is probably needlessly complicated because the parsing method
// used to be fixed. These two can now be matched to each other.
[this](QAbstractSocket::NetworkLayerProtocol protocol) -> CommandLine {
Q_UNUSED(protocol)
return {filePath("netstat"), {"-na"}};
},
[](const QByteArray &output) {
QList<Utils::Port> ports;
const QList<QByteArray> lines = output.split('\n');
for (const QByteArray &line : lines) {
const Port port(Utils::parseUsedPortFromNetstatOutput(line));
if (port.isValid() && !ports.contains(port))
ports.append(port);
}
return ports;
}
};
}
DeviceProcessList *QnxDevice::createProcessListModel(QObject *parent) const