|
|
@ -16,9 +16,9 @@ QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) : |
|
|
|
void QGCPendingParamWidget::connectToParamManager() |
|
|
|
void QGCPendingParamWidget::connectToParamManager() |
|
|
|
{ |
|
|
|
{ |
|
|
|
paramMgr = mav->getParamManager(); |
|
|
|
paramMgr = mav->getParamManager(); |
|
|
|
//TODO route via paramManager instead?
|
|
|
|
|
|
|
|
// Listen to updated param signals from the data model
|
|
|
|
// 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 ))); |
|
|
|
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); |
|
|
|
|
|
|
|
|
|
|
|
// Listen to communications status messages so we can display them
|
|
|
|
// Listen to communications status messages so we can display them
|
|
|
@ -29,9 +29,8 @@ void QGCPendingParamWidget::connectToParamManager() |
|
|
|
|
|
|
|
|
|
|
|
void QGCPendingParamWidget::disconnectFromParamManager() |
|
|
|
void QGCPendingParamWidget::disconnectFromParamManager() |
|
|
|
{ |
|
|
|
{ |
|
|
|
//TODO route via paramManager instead?
|
|
|
|
|
|
|
|
// Listen to updated param signals from the data model
|
|
|
|
// 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 ))); |
|
|
|
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); |
|
|
|
|
|
|
|
|
|
|
|
// Listen to communications status messages so we can display them
|
|
|
|
// Listen to communications status messages so we can display them
|
|
|
@ -76,7 +75,40 @@ void QGCPendingParamWidget::handlePendingParamUpdate(int compId, const QString& |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
//we don't display non-pending items
|
|
|
|
//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<QString, QTreeWidgetItem*>* 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(); |
|
|
|
updatingParamNameLock.clear(); |
|
|
|