Commit 0ce1bd4d authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #1666 from dogmaphobic/udpLinkFixes

Fixed a few issues with target UDP hosts.
parents 21d48a5b 07239b0e
......@@ -368,6 +368,7 @@ void UDPConfiguration::copyFrom(LinkConfiguration *source)
UDPConfiguration* usource = dynamic_cast<UDPConfiguration*>(source);
Q_ASSERT(usource != NULL);
_localPort = usource->localPort();
_hosts.clear();
QString host;
int port;
if(usource->firstHost(host, port)) {
......@@ -407,7 +408,7 @@ void UDPConfiguration::addHost(const QString& host, int port)
qWarning() << "UDP:" << "Could not resolve host:" << host << "port:" << port;
} else {
_hosts[ipAdd] = port;
qDebug() << "UDP:" << "Adding Host:" << ipAdd << ":" << port;
//qDebug() << "UDP:" << "Adding Host:" << ipAdd << ":" << port;
}
}
}
......
......@@ -72,13 +72,16 @@ void QGCUDPLinkConfiguration::_editHost(int row)
{
if(row < _viewModel->hosts.count()) {
bool ok;
QString oldName = _viewModel->hosts.at(row);
QString hostName = QInputDialog::getText(
this, tr("Edit a MAVLink host target"),
tr("Host (hostname:port): "), QLineEdit::Normal, _viewModel->hosts.at(row), &ok);
tr("Host (hostname:port): "), QLineEdit::Normal, oldName, &ok);
if (ok && !hostName.isEmpty()) {
_viewModel->beginChange();
_viewModel->hosts.replace(row, hostName);
_viewModel->endChange();
_config->removeHost(oldName);
_config->addHost(hostName);
}
}
}
......@@ -119,7 +122,9 @@ void QGCUDPLinkConfiguration::on_removeHost_clicked()
{
QModelIndex index = _ui->listView->currentIndex();
if(index.row() < _viewModel->hosts.count()) {
QString oldName = _viewModel->hosts.at(index.row());
_viewModel->hosts.removeAt(index.row());
_config->removeHost(oldName);
_reloadList();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment