Commit fb50a3cd authored by tstellanova's avatar tstellanova

fix slot wiring; debounce echo from data model

parent d907b934
......@@ -224,11 +224,7 @@ void UASParameterCommsMgr::resetAfterListReceive()
transmissionListMode = false;
transmissionListSizeKnown.clear();
//TODO we shouldn't clear missingPackets because other transactions might be using them?
//for list reception we only clear receive packets?
// foreach (int key, transmissionMissingPackets.keys()) {
// transmissionMissingPackets.value(key)->clear();
// }
//We shouldn't clear missingPackets because other transactions might be using them?
}
......
......@@ -66,8 +66,8 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
connect(paramDataModel, SIGNAL(parameterUpdated(int, QString , QVariant )),
this, SLOT(handleParameterUpdate(int,QString,QVariant)));
connect(paramDataModel, SIGNAL(pendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending)),
this, SLOT(handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending)));
connect(paramDataModel, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
// Listen for param list reload finished
connect(paramCommsMgr, SIGNAL(parameterListUpToDate()),
......@@ -348,6 +348,7 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
}
//update the parameterItem's data
updatedLineItem_weak = parameterItem; //keep a temporary ref to the item that's being updated
if (value.type() == QVariant::Char) {
parameterItem->setData(1, Qt::DisplayRole, value.toUInt());
}
......@@ -363,24 +364,30 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
parameterItem->setTextColor(0, QGC::colorDarkWhite);
parameterItem->setTextColor(1, QGC::colorDarkWhite);
updatedLineItem_weak = NULL;
return parameterItem;
}
void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* current, int column)
void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column)
{
if (current && column > 0) {
QTreeWidgetItem* parent = current->parent();
if (paramItem && column > 0) {
if (paramItem == updatedLineItem_weak) {
//ignore updates reflected back from the data model, to avoid infinite loop
return;
}
QTreeWidgetItem* parent = paramItem->parent();
while (parent->parent() != NULL) {
parent = parent->parent();
}
// Parent is now top-level component
int componentId = componentItems->key(parent);
QString key = current->data(0, Qt::DisplayRole).toString();
QVariant value = current->data(1, Qt::DisplayRole);
QString key = paramItem->data(0, Qt::DisplayRole).toString();
QVariant value = paramItem->data(1, Qt::DisplayRole);
bool pending = paramDataModel->updatePendingParamWithValue(componentId,key,value);
......@@ -389,19 +396,19 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* current, int column)
// 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(' ')));
if (current == tree->currentItem()) {
if (paramItem == tree->currentItem()) {
//need to unset current item to clear highlighting (green by default)
tree->setCurrentItem(NULL); //clear the selected line
}
current->setBackground(0, QBrush(QColor(QGC::colorOrange)));
current->setBackground(1, QBrush(QColor(QGC::colorOrange)));
paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange)));
paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange)));
}
else {
QMap<QString , QVariant>* pendingParams = paramDataModel->getPendingParamsForComponent(componentId);
int pendingCount = pendingParams->count();
statusLabel->setText(tr("Pending items: %1").arg(pendingCount));
current->setBackground(0, Qt::NoBrush);
current->setBackground(1, Qt::NoBrush);
paramItem->setBackground(0, Qt::NoBrush);
paramItem->setBackground(1, Qt::NoBrush);
}
}
......
......@@ -100,6 +100,7 @@ protected:
QLabel* statusLabel; ///< User-facing parameter status label
QMap<int, QTreeWidgetItem*>* componentItems; ///< The tree of component items, stored by component ID
QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups to organize component items
QTreeWidgetItem* updatedLineItem_weak;///< weak ref to user-edited line
};
......
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