1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GCS-Handle reload for unbounded objects

This commit is contained in:
PT_Dreamer 2012-08-15 22:50:09 +01:00
parent a78766c7b2
commit 57d4aaaf17
3 changed files with 26 additions and 9 deletions

View File

@ -56,14 +56,16 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent
// using objrelation dynamic property // using objrelation dynamic property
autoLoadWidgets(); autoLoadWidgets();
QList<int> reloadGroups;
reloadGroups<<1;
// Add some widgets and UAVObjects to track widget dirty state // Add some widgets and UAVObjects to track widget dirty state
// and monitor UAVObject changes in addition to autoloaded ones // and monitor UAVObject changes in addition to autoloaded ones
addWidget(m_camerastabilization->enableCameraStabilization); addWidget(m_camerastabilization->enableCameraStabilization);
addWidget(m_camerastabilization->rollChannel); addWidget(m_camerastabilization->rollChannel);
addWidget(m_camerastabilization->pitchChannel); addWidget(m_camerastabilization->pitchChannel);
addWidget(m_camerastabilization->yawChannel); addWidget(m_camerastabilization->yawChannel);
addUAVObject("HwSettings"); addUAVObject("HwSettings",&reloadGroups);
addUAVObject("MixerSettings"); addUAVObject("MixerSettings",&reloadGroups);
// To set special widgets to defaults when requested // To set special widgets to defaults when requested
connect(this, SIGNAL(defaultRequested(int)), this, SLOT(defaultRequestedSlot(int))); connect(this, SIGNAL(defaultRequested(int)), this, SLOT(defaultRequestedSlot(int)));

View File

@ -57,9 +57,9 @@ void ConfigTaskWidget::addWidget(QWidget * widget)
* Add an object to the management system * Add an object to the management system
* @param objectName name of the object to add to the management system * @param objectName name of the object to add to the management system
*/ */
void ConfigTaskWidget::addUAVObject(QString objectName) void ConfigTaskWidget::addUAVObject(QString objectName,QList<int> * reloadGroups)
{ {
addUAVObjectToWidgetRelation(objectName,"",NULL); addUAVObjectToWidgetRelation(objectName,"",NULL,0,1,false,reloadGroups);
} }
/** /**
* Add an UAVObject field to widget relation to the management system * Add an UAVObject field to widget relation to the management system
@ -148,7 +148,21 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
} }
if(widget==NULL) if(widget==NULL)
{ {
// do nothing if(defaultReloadGroups && obj)
{
foreach(int i,*defaultReloadGroups)
{
if(this->defaultReloadGroups.contains(i))
{
this->defaultReloadGroups.value(i)->append(ow);
}
else
{
this->defaultReloadGroups.insert(i,new QList<objectToWidget*>());
this->defaultReloadGroups.value(i)->append(ow);
}
}
}
} }
else else
{ {
@ -537,7 +551,7 @@ bool ConfigTaskWidget::addShadowWidget(QString object, QString field, QWidget *w
{ {
foreach(objectToWidget * oTw,objOfInterest) foreach(objectToWidget * oTw,objOfInterest)
{ {
if(!oTw->object || !oTw->widget) if(!oTw->object || !oTw->widget || !oTw->field)
continue; continue;
if(oTw->object->getName()==object && oTw->field->getName()==field && oTw->index==index && oTw->object->getInstID()==instID) if(oTw->object->getName()==object && oTw->field->getName()==field && oTw->index==index && oTw->object->getInstID()==instID)
{ {
@ -772,7 +786,7 @@ void ConfigTaskWidget::defaultButtonClicked()
QList<objectToWidget*> * list=defaultReloadGroups.value(group); QList<objectToWidget*> * list=defaultReloadGroups.value(group);
foreach(objectToWidget * oTw,*list) foreach(objectToWidget * oTw,*list)
{ {
if(!oTw->object) if(!oTw->object || !oTw->field)
continue; continue;
UAVDataObject * temp=((UAVDataObject*)oTw->object)->dirtyClone(); UAVDataObject * temp=((UAVDataObject*)oTw->object)->dirtyClone();
setWidgetFromField(oTw->widget,temp->getField(oTw->field->getName()),oTw->index,oTw->scale,oTw->isLimited); setWidgetFromField(oTw->widget,temp->getField(oTw->field->getName()),oTw->index,oTw->scale,oTw->isLimited);
@ -810,7 +824,8 @@ void ConfigTaskWidget::reloadButtonClicked()
if(timeOut->isActive()) if(timeOut->isActive())
{ {
oTw->object->requestUpdate(); oTw->object->requestUpdate();
setWidgetFromField(oTw->widget,oTw->field,oTw->index,oTw->scale,oTw->isLimited); if(oTw->widget)
setWidgetFromField(oTw->widget,oTw->field,oTw->index,oTw->scale,oTw->isLimited);
} }
timeOut->stop(); timeOut->stop();
} }

View File

@ -93,7 +93,7 @@ public:
UAVObjectManager* getObjectManager(); UAVObjectManager* getObjectManager();
static double listMean(QList<double> list); static double listMean(QList<double> list);
void addUAVObject(QString objectName); void addUAVObject(QString objectName, QList<int> *reloadGroups=NULL);
void addWidget(QWidget * widget); void addWidget(QWidget * widget);
void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget,int index=0,double scale=1,bool isLimited=false,QList<int>* defaultReloadGroups=0,quint32 instID=0); void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget,int index=0,double scale=1,bool isLimited=false,QList<int>* defaultReloadGroups=0,quint32 instID=0);