1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +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
autoLoadWidgets();
QList<int> reloadGroups;
reloadGroups<<1;
// Add some widgets and UAVObjects to track widget dirty state
// and monitor UAVObject changes in addition to autoloaded ones
addWidget(m_camerastabilization->enableCameraStabilization);
addWidget(m_camerastabilization->rollChannel);
addWidget(m_camerastabilization->pitchChannel);
addWidget(m_camerastabilization->yawChannel);
addUAVObject("HwSettings");
addUAVObject("MixerSettings");
addUAVObject("HwSettings",&reloadGroups);
addUAVObject("MixerSettings",&reloadGroups);
// To set special widgets to defaults when requested
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
* @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
@ -148,7 +148,21 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
}
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
{
@ -537,7 +551,7 @@ bool ConfigTaskWidget::addShadowWidget(QString object, QString field, QWidget *w
{
foreach(objectToWidget * oTw,objOfInterest)
{
if(!oTw->object || !oTw->widget)
if(!oTw->object || !oTw->widget || !oTw->field)
continue;
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);
foreach(objectToWidget * oTw,*list)
{
if(!oTw->object)
if(!oTw->object || !oTw->field)
continue;
UAVDataObject * temp=((UAVDataObject*)oTw->object)->dirtyClone();
setWidgetFromField(oTw->widget,temp->getField(oTw->field->getName()),oTw->index,oTw->scale,oTw->isLimited);
@ -810,7 +824,8 @@ void ConfigTaskWidget::reloadButtonClicked()
if(timeOut->isActive())
{
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();
}

View File

@ -93,7 +93,7 @@ public:
UAVObjectManager* getObjectManager();
static double listMean(QList<double> list);
void addUAVObject(QString objectName);
void addUAVObject(QString objectName, QList<int> *reloadGroups=NULL);
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);