diff --git a/src/uas/QGCUASParamManager.cc b/src/uas/QGCUASParamManager.cc index 68f1ed0dfc53c91e9b9ef5fc3ed9d38811f1ca39..aa4bd8174b8cdc39ea17186516970bf8fdf64bb0 100644 --- a/src/uas/QGCUASParamManager.cc +++ b/src/uas/QGCUASParamManager.cc @@ -40,6 +40,15 @@ void QGCUASParamManager::connectToModelAndComms() connect(paramCommsMgr, SIGNAL(parameterListUpToDate()), this, SIGNAL(parameterListUpToDate())); + + // Pass along data model updates + connect(¶mDataModel, SIGNAL(parameterUpdated(int, QString , QVariant )), + this, SIGNAL(parameterUpdated(int, QString , QVariant ))); + + connect(¶mDataModel, SIGNAL(pendingParamUpdate(int , const QString& , QVariant , bool )), + this, SIGNAL(pendingParamUpdate(int , const QString& , QVariant , bool ))); + + } diff --git a/src/uas/QGCUASParamManager.h b/src/uas/QGCUASParamManager.h index 81a12575a506e291ca0768407f326b51013b6a66..c0cf6cd21add82e16d4d2061a0136a6b7466048c 100644 --- a/src/uas/QGCUASParamManager.h +++ b/src/uas/QGCUASParamManager.h @@ -72,6 +72,12 @@ signals: /** @brief We have received a complete list of all parameters onboard the MAV */ void parameterListUpToDate(); + /** @brief We've received an update of a parameter's value */ + void parameterUpdated(int compId, QString paramName, QVariant value); + + /** @brief Notifies listeners that a param was added to or removed from the pending list */ + void pendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending); + public slots: diff --git a/src/ui/QGCBaseParamWidget.cc b/src/ui/QGCBaseParamWidget.cc index d80e53693eadce2dd5469cf82ee854d79db069eb..f1d8d60a73c4c3f868ecb820074165b75a6716b0 100644 --- a/src/ui/QGCBaseParamWidget.cc +++ b/src/ui/QGCBaseParamWidget.cc @@ -53,10 +53,10 @@ void QGCBaseParamWidget::connectToParamManager() paramMgr = mav->getParamManager(); //TODO route via paramManager instead? // Listen to updated param signals from the data model - connect(paramMgr->dataModel(), SIGNAL(parameterUpdated(int, QString , QVariant )), + connect(paramMgr, SIGNAL(parameterUpdated(int, QString , QVariant )), this, SLOT(handleOnboardParamUpdate(int,QString,QVariant))); - connect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), + connect(paramMgr, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); // Listen for param list reload finished @@ -71,10 +71,10 @@ void QGCBaseParamWidget::connectToParamManager() void QGCBaseParamWidget::disconnectFromParamManager() { - disconnect(paramMgr->dataModel(), SIGNAL(parameterUpdated(int, QString , QVariant )), + disconnect(paramMgr, SIGNAL(parameterUpdated(int, QString , QVariant )), this, SLOT(handleOnboardParamUpdate(int,QString,QVariant))); - disconnect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), + disconnect(paramMgr, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); disconnect(paramMgr, SIGNAL(parameterListUpToDate()), diff --git a/src/ui/QGCPX4VehicleConfig.cc b/src/ui/QGCPX4VehicleConfig.cc index dcd406e582212f03dcb7e523dee481005d420dcf..9f6695ec4a78f1e3ae81742f5dba850435ceb077 100644 --- a/src/ui/QGCPX4VehicleConfig.cc +++ b/src/ui/QGCPX4VehicleConfig.cc @@ -103,12 +103,18 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : ui->radio8Widget->setOrientation(Qt::Horizontal); ui->radio8Widget->setName("Radio 8"); - connect(ui->rcMenuButton,SIGNAL(clicked()),this,SLOT(rcMenuButtonClicked())); - connect(ui->sensorMenuButton,SIGNAL(clicked()),this,SLOT(sensorMenuButtonClicked())); - connect(ui->generalMenuButton,SIGNAL(clicked()),this,SLOT(generalMenuButtonClicked())); - connect(ui->advancedMenuButton,SIGNAL(clicked()),this,SLOT(advancedMenuButtonClicked())); - connect(ui->airframeMenuButton, SIGNAL(clicked()), this, SLOT(airframeMenuButtonClicked())); - connect(ui->firmwareMenuButton, SIGNAL(clicked()), this, SLOT(firmwareButtonClicked())); + connect(ui->rcMenuButton,SIGNAL(clicked()), + this,SLOT(rcMenuButtonClicked())); + connect(ui->sensorMenuButton,SIGNAL(clicked()), + this,SLOT(sensorMenuButtonClicked())); + connect(ui->generalMenuButton,SIGNAL(clicked()), + this,SLOT(generalMenuButtonClicked())); + connect(ui->advancedMenuButton,SIGNAL(clicked()), + this,SLOT(advancedMenuButtonClicked())); + connect(ui->airframeMenuButton, SIGNAL(clicked()), + this, SLOT(airframeMenuButtonClicked())); + connect(ui->firmwareMenuButton, SIGNAL(clicked()), + this, SLOT(firmwareMenuButtonClicked())); ui->rcCalibrationButton->setCheckable(true); connect(ui->rcCalibrationButton, SIGNAL(clicked(bool)), this, SLOT(toggleCalibrationRC(bool))); diff --git a/src/ui/QGCPendingParamWidget.cc b/src/ui/QGCPendingParamWidget.cc index c5fb5a010f0dd57106413191ec5083697e1c17ef..35402d995e3220617509004ce7f46466bee2866c 100644 --- a/src/ui/QGCPendingParamWidget.cc +++ b/src/ui/QGCPendingParamWidget.cc @@ -16,9 +16,9 @@ QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) : void QGCPendingParamWidget::connectToParamManager() { paramMgr = mav->getParamManager(); - //TODO route via paramManager instead? + // Listen to updated param signals from the data model - connect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), + connect(paramMgr, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); // Listen to communications status messages so we can display them @@ -29,9 +29,8 @@ void QGCPendingParamWidget::connectToParamManager() void QGCPendingParamWidget::disconnectFromParamManager() { - //TODO route via paramManager instead? // Listen to updated param signals from the data model - disconnect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), + disconnect(paramMgr, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); // Listen to communications status messages so we can display them @@ -76,7 +75,40 @@ void QGCPendingParamWidget::handlePendingParamUpdate(int compId, const QString& } else { //we don't display non-pending items - paramItem->parent()->removeChild(paramItem); + QTreeWidgetItem* groupItem = paramItem->parent(); + if (NULL != groupItem) { + tree->setUpdatesEnabled(false); + QTreeWidgetItem* componentItem = NULL; + if (1 == groupItem->childCount()) { + componentItem = groupItem->parent(); + } + + //always remove the actual paramItem from its parent + groupItem->removeChild(paramItem); + + //now we may need to remove the groupItem if it has no more children + if (NULL != componentItem) { + //remove the group from our internal data structures + QMap* compParamGroups = paramGroups.value(compId); + QString groupStr = paramName.section("_", 0, 0, QString::SectionSkipEmpty); + compParamGroups->remove(groupStr); + //remove the group item from componentItems + componentItems->value(compId)->removeChild(groupItem); + // remove the group item from the tree widget itself + componentItem->removeChild(groupItem); + + if (0 == componentItem->childCount()) { + //the component itself no longer has any pending changes: remove it + paramGroups.remove(compId); + componentItems->remove(compId); + QTreeWidgetItem* compTop = tree->takeTopLevelItem(tree->indexOfTopLevelItem(componentItem)); + delete compTop; //we own it after take + } + } + tree->setUpdatesEnabled(true); + tree->update(); + + } } updatingParamNameLock.clear();