Browse Source

Another cleanup round

QGC4.4
Lorenz Meier 12 years ago
parent
commit
d55937a1c8
  1. 9
      src/comm/SerialLink.cc
  2. 2
      src/ui/QGCPX4VehicleConfig.cc
  3. 12
      src/ui/QGCToolBar.cc
  4. 20
      src/ui/uas/UASListWidget.cc
  5. 1
      src/ui/uas/UASListWidget.h

9
src/comm/SerialLink.cc

@ -28,8 +28,6 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
m_stopp(false), m_stopp(false),
m_reqReset(false) m_reqReset(false)
{ {
qDebug() << "create SerialLink " << portname << baudRate << hardwareFlowControl
<< parity << dataBits << stopBits;
// Setup settings // Setup settings
m_portName = portname.trimmed(); m_portName = portname.trimmed();
@ -38,8 +36,6 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
m_portName = m_ports.first().trimmed(); m_portName = m_ports.first().trimmed();
} }
qDebug() << "m_portName " << m_portName;
// Set unique ID and add link to the list of links // Set unique ID and add link to the list of links
m_id = getNextLinkId(); m_id = getNextLinkId();
@ -66,6 +62,11 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
m_stopBits = stopBits; m_stopBits = stopBits;
loadSettings(); loadSettings();
qDebug() << "create SerialLink " << portname << baudRate << hardwareFlowControl
<< parity << dataBits << stopBits;
qDebug() << "m_portName " << m_portName;
LinkManager::instance()->add(this); LinkManager::instance()->add(this);
} }
void SerialLink::requestReset() void SerialLink::requestReset()

2
src/ui/QGCPX4VehicleConfig.cc

@ -223,6 +223,8 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
updateTimer.setInterval(150); updateTimer.setInterval(150);
connect(&updateTimer, SIGNAL(timeout()), this, SLOT(updateView())); connect(&updateTimer, SIGNAL(timeout()), this, SLOT(updateView()));
updateTimer.start(); updateTimer.start();
firmwareMenuButtonClicked();
} }
QGCPX4VehicleConfig::~QGCPX4VehicleConfig() QGCPX4VehicleConfig::~QGCPX4VehicleConfig()

12
src/ui/QGCToolBar.cc

@ -182,8 +182,8 @@ void QGCToolBar::createUI()
baudcomboBox->addItem("921600", 921600); baudcomboBox->addItem("921600", 921600);
baudcomboBox->setCurrentIndex(baudcomboBox->findData(57600)); baudcomboBox->setCurrentIndex(baudcomboBox->findData(57600));
addWidget(baudcomboBox); addWidget(baudcomboBox);
connect(baudcomboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(baudSelected(int))); connect(baudcomboBox, SIGNAL(activated(int)), this, SLOT(baudSelected(int)));
connect(portComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(portSelected(int))); connect(portComboBox, SIGNAL(activated(int)), this, SLOT(portSelected(int)));
connectButton = new QPushButton(tr("Connect"), this); connectButton = new QPushButton(tr("Connect"), this);
connectButton->setObjectName("connectButton"); connectButton->setObjectName("connectButton");
@ -666,6 +666,10 @@ void QGCToolBar::updateComboBox()
{ {
if (currentLink) if (currentLink)
{ {
// Do not update if not visible
if (!portComboBox->isVisible())
return;
SerialLink *slink = qobject_cast<SerialLink*>(currentLink); SerialLink *slink = qobject_cast<SerialLink*>(currentLink);
QList<QString> portlist = slink->getCurrentPorts(); QList<QString> portlist = slink->getCurrentPorts();
foreach (QString port, portlist) foreach (QString port, portlist)
@ -715,6 +719,8 @@ void QGCToolBar::updateLinkState(bool connected)
connectButton->blockSignals(true); connectButton->blockSignals(true);
connectButton->setChecked(true); connectButton->setChecked(true);
connectButton->blockSignals(false); connectButton->blockSignals(false);
portComboBox->hide();
baudcomboBox->hide();
} }
else else
{ {
@ -722,6 +728,8 @@ void QGCToolBar::updateLinkState(bool connected)
connectButton->blockSignals(true); connectButton->blockSignals(true);
connectButton->setChecked(false); connectButton->setChecked(false);
connectButton->blockSignals(false); connectButton->blockSignals(false);
portComboBox->show();
baudcomboBox->show();
} }
} }

20
src/ui/uas/UASListWidget.cc

@ -64,6 +64,8 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent),
this->setVisible(false); this->setVisible(false);
connect(LinkManager::instance(), SIGNAL(linkRemoved(LinkInterface*)), this, SLOT(removeLink(LinkInterface*)));
// Listen for when UASes are added or removed. This does not manage the UASView // Listen for when UASes are added or removed. This does not manage the UASView
// widgets that are displayed within this widget. // widgets that are displayed within this widget.
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
@ -96,12 +98,30 @@ void UASListWidget::changeEvent(QEvent *e)
} }
} }
// XXX This is just to prevent
// upfront crashes, will probably need further inspection
void UASListWidget::removeLink(LinkInterface* link)
{
QGroupBox* box = linkToBoxMapping.value(link, NULL);
if (box) {
// Just stop updating the status for now - we should
// remove the UAS probably
linkToBoxMapping.remove(link);
}
}
void UASListWidget::updateStatus() void UASListWidget::updateStatus()
{ {
QMapIterator<LinkInterface*, QGroupBox*> i(linkToBoxMapping); QMapIterator<LinkInterface*, QGroupBox*> i(linkToBoxMapping);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
LinkInterface* link = i.key(); LinkInterface* link = i.key();
// Paranoid sanity check
if (!LinkManager::instance()->getLinks().contains(link))
continue;
if (!link) if (!link)
continue; continue;

1
src/ui/uas/UASListWidget.h

@ -53,6 +53,7 @@ public slots:
void addUAS(UASInterface* uas); void addUAS(UASInterface* uas);
void activeUAS(UASInterface* uas); void activeUAS(UASInterface* uas);
void removeUAS(UASInterface* uas); void removeUAS(UASInterface* uas);
void removeLink(LinkInterface* link);
protected: protected:
// Keep a mapping from UASes to their GroupBox. Useful for determining when groupboxes are empty. // Keep a mapping from UASes to their GroupBox. Useful for determining when groupboxes are empty.

Loading…
Cancel
Save