GUI Milestone 4
This commit is contained in:
parent
282136632e
commit
a369381b6c
5 changed files with 177 additions and 16 deletions
|
|
@ -318,11 +318,43 @@ void WarpGraphModel::refreshFromClient() {
|
|||
for (const auto &nodeInfo : nodesResult.value) {
|
||||
seenPwIds.insert(nodeInfo.id.value);
|
||||
|
||||
WarpNodeType nodeType = classifyNode(nodeInfo);
|
||||
bool isStream = nodeType == WarpNodeType::kApplication;
|
||||
if (isStream && nodeInfo.name.empty() &&
|
||||
nodeInfo.application_name.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto existing = m_pwToQt.find(nodeInfo.id.value);
|
||||
if (existing != m_pwToQt.end()) {
|
||||
QtNodes::NodeId qtId = existing->second;
|
||||
auto &data = m_nodes[qtId];
|
||||
data.info = nodeInfo;
|
||||
|
||||
bool portsMissing =
|
||||
data.inputPorts.empty() && data.outputPorts.empty();
|
||||
if (portsMissing) {
|
||||
auto portsResult = m_client->ListPorts(nodeInfo.id);
|
||||
if (portsResult.ok() && !portsResult.value.empty()) {
|
||||
for (const auto &port : portsResult.value) {
|
||||
if (port.is_input) {
|
||||
data.inputPorts.push_back(port);
|
||||
} else {
|
||||
data.outputPorts.push_back(port);
|
||||
}
|
||||
}
|
||||
std::sort(data.inputPorts.begin(), data.inputPorts.end(),
|
||||
[](const auto &a, const auto &b) {
|
||||
return a.name < b.name;
|
||||
});
|
||||
std::sort(data.outputPorts.begin(), data.outputPorts.end(),
|
||||
[](const auto &a, const auto &b) {
|
||||
return a.name < b.name;
|
||||
});
|
||||
Q_EMIT nodeUpdated(qtId);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ghostNodes.erase(qtId)) {
|
||||
Q_EMIT nodeUpdated(qtId);
|
||||
}
|
||||
|
|
@ -392,7 +424,14 @@ void WarpGraphModel::refreshFromClient() {
|
|||
|
||||
auto [nodeIt, _] = m_nodes.emplace(qtId, std::move(data));
|
||||
m_pwToQt.emplace(nodeInfo.id.value, qtId);
|
||||
m_positions.emplace(qtId, nextPosition(nodeIt->second));
|
||||
|
||||
auto pendingIt = m_pendingPositions.find(nodeInfo.name);
|
||||
if (pendingIt != m_pendingPositions.end()) {
|
||||
m_positions.emplace(qtId, pendingIt->second);
|
||||
m_pendingPositions.erase(pendingIt);
|
||||
} else {
|
||||
m_positions.emplace(qtId, nextPosition(nodeIt->second));
|
||||
}
|
||||
|
||||
Q_EMIT nodeCreated(qtId);
|
||||
}
|
||||
|
|
@ -510,6 +549,11 @@ QtNodes::NodeId WarpGraphModel::qtNodeIdForPw(uint32_t pwNodeId) const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void WarpGraphModel::setPendingPosition(const std::string &nodeName,
|
||||
QPointF pos) {
|
||||
m_pendingPositions[nodeName] = pos;
|
||||
}
|
||||
|
||||
QString WarpGraphModel::captionForNode(const warppipe::NodeInfo &info) {
|
||||
if (!info.description.empty()) {
|
||||
return QString::fromStdString(info.description);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue