Browse Source

Begin to connect separate param widgets via data model

still some remaining issues with pending line items bouncing back from
data model
QGC4.4
tstellanova 12 years ago
parent
commit
9af23ff72c
  1. 8
      src/uas/UASParameterCommsMgr.cc
  2. 35
      src/ui/QGCParamWidget.cc
  3. 1
      src/ui/QGCParamWidget.h

8
src/uas/UASParameterCommsMgr.cc

@ -50,6 +50,7 @@ void UASParameterCommsMgr::loadParamCommsSettings() @@ -50,6 +50,7 @@ void UASParameterCommsMgr::loadParamCommsSettings()
int val = settings.value("PARAMETER_RETRANSMISSION_TIMEOUT", retransmissionTimeout).toInt(&ok);
if (ok) {
retransmissionTimeout = val;
qDebug() << "retransmissionTimeout" << retransmissionTimeout;
}
val = settings.value("PARAMETER_REWRITE_TIMEOUT", rewriteTimeout).toInt(&ok);
if (ok) {
@ -240,6 +241,8 @@ void UASParameterCommsMgr::retransmissionGuardTick() @@ -240,6 +241,8 @@ void UASParameterCommsMgr::retransmissionGuardTick()
setRetransmissionGuardEnabled(true);
return;
}
qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD ACTIVE after" << elapsed;
if (transmissionActive) {
@ -250,6 +253,8 @@ void UASParameterCommsMgr::retransmissionGuardTick() @@ -250,6 +253,8 @@ void UASParameterCommsMgr::retransmissionGuardTick()
setParameterStatusMsg(tr("TIMEOUT: Re-requesting param list"),ParamCommsStatusLevel_Warning);
listRecvTimeout = curTime + 10000;
mav->requestParameters();
//reset the timer
setRetransmissionGuardEnabled(true);
}
return;
}
@ -270,7 +275,6 @@ void UASParameterCommsMgr::retransmissionGuardTick() @@ -270,7 +275,6 @@ void UASParameterCommsMgr::retransmissionGuardTick()
return;
}
qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD ACTIVE, CHECKING FOR DROPS..";
resendReadWriteRequests();
}
else {
@ -443,7 +447,7 @@ void UASParameterCommsMgr::receivedParameterUpdate(int uas, int compId, int para @@ -443,7 +447,7 @@ void UASParameterCommsMgr::receivedParameterUpdate(int uas, int compId, int para
// There is only one transmission timeout for all components
// since components do not manage their transmission,
// the longest timeout is safe for all components.
quint64 thisTransmissionTimeout = QGC::groundTimeMilliseconds() + ((paramCount)*retransmissionTimeout);
quint64 thisTransmissionTimeout = QGC::groundTimeMilliseconds() + (paramCount*retransmissionTimeout);
if (thisTransmissionTimeout > transmissionTimeout) {
transmissionTimeout = thisTransmissionTimeout;
}

35
src/ui/QGCParamWidget.cc

@ -202,7 +202,20 @@ void QGCParamWidget::addComponentItem(int compId, QString compName) @@ -202,7 +202,20 @@ void QGCParamWidget::addComponentItem(int compId, QString compName)
void QGCParamWidget::handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending)
{
qDebug() << "handlePendingParamUpdate:" << paramName << "with updatedLineItem_weak:" << updatedLineItem_weak;
if (updatedLineItem_weak) {
QString key = updatedLineItem_weak->data(0, Qt::DisplayRole).toString();
if (paramName == key) {
//debounce echo from data model
return;
}
}
QTreeWidgetItem* paramItem = updateParameterDisplay(compId,paramName,value);
if (updatedLineItem_weak == NULL) {
updatedLineItem_weak = paramItem;
}
if (isPending) {
paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange)));
paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange)));
@ -327,6 +340,8 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para @@ -327,6 +340,8 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
parameterItem->setData(1, Qt::DisplayRole, value);
}
parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable);
updatedLineItem_weak = parameterItem; //keep a temporary ref to the item that's being updated
//TODO insert alphabetically
parentItem->addChild(parameterItem);
@ -347,8 +362,9 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para @@ -347,8 +362,9 @@ 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
//update the parameterItem's data
if (value.type() == QVariant::Char) {
parameterItem->setData(1, Qt::DisplayRole, value.toUInt());
}
@ -357,14 +373,16 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para @@ -357,14 +373,16 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
}
}
// Reset background color
parameterItem->setBackground(0, Qt::NoBrush);
parameterItem->setBackground(1, Qt::NoBrush);
if (parameterItem) {
// Reset background color
parameterItem->setBackground(0, Qt::NoBrush);
parameterItem->setBackground(1, Qt::NoBrush);
parameterItem->setTextColor(0, QGC::colorDarkWhite);
parameterItem->setTextColor(1, QGC::colorDarkWhite);
parameterItem->setTextColor(0, QGC::colorDarkWhite);
parameterItem->setTextColor(1, QGC::colorDarkWhite);
updatedLineItem_weak = NULL;
updatedLineItem_weak = NULL;
}
return parameterItem;
}
@ -374,7 +392,8 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para @@ -374,7 +392,8 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column)
{
if (paramItem && column > 0) {
if (paramItem == updatedLineItem_weak) {
if (!paramItem->isSelected() || (paramItem == updatedLineItem_weak)) {
//ignore updates reflected back from the data model, to avoid infinite loop
return;
}

1
src/ui/QGCParamWidget.h

@ -101,6 +101,7 @@ protected: @@ -101,6 +101,7 @@ protected:
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
// QTreeWidgetItem* updatedPendingItem_weak;///< weak ref to pending-modified line
};

Loading…
Cancel
Save