Commit 98f2ae23 authored by tstellanova's avatar tstellanova

more strict locking of currently updating parameter

parent 656841a6
...@@ -249,7 +249,9 @@ void QGCParamWidget::handleParameterListUpToDate() ...@@ -249,7 +249,9 @@ void QGCParamWidget::handleParameterListUpToDate()
QMap<QString, QVariant>* paramPairs = onboardParams->value(compId); QMap<QString, QVariant>* paramPairs = onboardParams->value(compId);
QMap<QString, QVariant>::iterator j; QMap<QString, QVariant>::iterator j;
for (j = paramPairs->begin(); j != paramPairs->end(); j++) { for (j = paramPairs->begin(); j != paramPairs->end(); j++) {
updatingParamNameLock = j.key();
updateParameterDisplay(compId, j.key(),j.value()); updateParameterDisplay(compId, j.key(),j.value());
updatingParamNameLock.clear();
} }
} }
...@@ -315,7 +317,7 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para ...@@ -315,7 +317,7 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
// qDebug() << "QGCParamWidget::updateParameterDisplay" << parameterName; // qDebug() << "QGCParamWidget::updateParameterDisplay" << parameterName;
// Reference to item in tree // Reference to item in tree
QTreeWidgetItem* parameterItem = NULL; QTreeWidgetItem* paramItem = NULL;
// Add component item if necessary // Add component item if necessary
if (!componentItems->contains(compId)) { if (!componentItems->contains(compId)) {
...@@ -326,24 +328,24 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para ...@@ -326,24 +328,24 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
//default parent item for this parameter widget item will be the top level component item //default parent item for this parameter widget item will be the top level component item
QTreeWidgetItem* parentItem = getParentWidgetItemForParam(compId,parameterName); QTreeWidgetItem* parentItem = getParentWidgetItemForParam(compId,parameterName);
if (parentItem) { if (parentItem) {
parameterItem = findChildWidgetItemForParam(parentItem,parameterName); paramItem = findChildWidgetItemForParam(parentItem,parameterName);
if (!parameterItem) { if (!paramItem) {
// Insert parameter into map // Insert parameter into map
QStringList plist; QStringList plist;
plist.append(parameterName); plist.append(parameterName);
// CREATE PARAMETER ITEM // CREATE PARAMETER ITEM
parameterItem = new QTreeWidgetItem(plist); paramItem = new QTreeWidgetItem(plist);
// CONFIGURE PARAMETER ITEM // CONFIGURE PARAMETER ITEM
if (value.type() == QVariant::Char) { if (value.type() == QVariant::Char) {
parameterItem->setData(1, Qt::DisplayRole, value.toUInt()); paramItem->setData(1, Qt::DisplayRole, value.toUInt());
} }
else { else {
parameterItem->setData(1, Qt::DisplayRole, value); paramItem->setData(1, Qt::DisplayRole, value);
} }
parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable); paramItem->setFlags(paramItem->flags() | Qt::ItemIsEditable);
//TODO insert alphabetically //TODO insert alphabetically
parentItem->addChild(parameterItem); parentItem->addChild(paramItem);
//only add the tooltip when the parameter item is first added //only add the tooltip when the parameter item is first added
QString paramDesc = paramDataModel->getParamDescription(parameterName); QString paramDesc = paramDataModel->getParamDescription(parameterName);
...@@ -357,30 +359,35 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para ...@@ -357,30 +359,35 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
else { else {
tooltipFormat = paramDesc; tooltipFormat = paramDesc;
} }
parameterItem->setToolTip(0, tooltipFormat); paramItem->setToolTip(0, tooltipFormat);
parameterItem->setToolTip(1, tooltipFormat); paramItem->setToolTip(1, tooltipFormat);
} }
} }
//update the parameterItem's data //update the parameterItem's data
if (value.type() == QVariant::Char) { if (value.type() == QVariant::Char) {
parameterItem->setData(1, Qt::DisplayRole, value.toUInt()); paramItem->setData(1, Qt::DisplayRole, value.toUInt());
} }
else { else {
parameterItem->setData(1, Qt::DisplayRole, value); paramItem->setData(1, Qt::DisplayRole, value);
} }
} }
if (parameterItem) { if (paramItem) {
// Reset background color // Reset background color
parameterItem->setBackground(0, Qt::NoBrush); paramItem->setBackground(0, Qt::NoBrush);
parameterItem->setBackground(1, Qt::NoBrush); paramItem->setBackground(1, Qt::NoBrush);
parameterItem->setTextColor(0, QGC::colorDarkWhite); paramItem->setTextColor(0, QGC::colorDarkWhite);
parameterItem->setTextColor(1, QGC::colorDarkWhite); paramItem->setTextColor(1, QGC::colorDarkWhite);
if (paramItem == tree->currentItem()) {
//need to unset current item to clear highlighting (green by default)
tree->setCurrentItem(NULL); //clear the selected line
}
} }
return parameterItem; return paramItem;
} }
...@@ -418,10 +425,6 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column ...@@ -418,10 +425,6 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column
// Set parameter on changed list to be transmitted to MAV // Set parameter on changed list to be transmitted to MAV
statusLabel->setText(tr("Pending: %1:%2: %3").arg(componentId).arg(key).arg(value.toFloat(), 5, 'f', 1, QChar(' '))); statusLabel->setText(tr("Pending: %1:%2: %3").arg(componentId).arg(key).arg(value.toFloat(), 5, 'f', 1, QChar(' ')));
if (paramItem == tree->currentItem()) {
//need to unset current item to clear highlighting (green by default)
tree->setCurrentItem(NULL); //clear the selected line
}
paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange))); paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange)));
paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange))); paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange)));
} }
...@@ -433,6 +436,12 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column ...@@ -433,6 +436,12 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column
paramItem->setBackground(1, Qt::NoBrush); paramItem->setBackground(1, Qt::NoBrush);
} }
if (paramItem == tree->currentItem()) {
//need to unset current item to clear highlighting (green by default)
tree->setCurrentItem(NULL); //clear the selected line
}
updatingParamNameLock.clear(); updatingParamNameLock.clear();
} }
} }
......
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