From 8c2dfea5a62fe2ff7eeacd981807a899ceadf231 Mon Sep 17 00:00:00 2001 From: Bryant Date: Sat, 8 Jun 2013 16:13:18 -0700 Subject: [PATCH] The QuickView now properly resets after the last UAS is deleted. --- src/ui/uas/UASQuickView.cc | 25 +++++++++++++++++++++---- src/ui/uas/UASQuickView.h | 4 ++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/ui/uas/UASQuickView.cc b/src/ui/uas/UASQuickView.cc index 1a6fcbd44..fcbfba717 100644 --- a/src/ui/uas/UASQuickView.cc +++ b/src/ui/uas/UASQuickView.cc @@ -15,7 +15,14 @@ UASQuickView::UASQuickView(QWidget *parent) : } this->setContextMenuPolicy(Qt::ActionsContextMenu); + addDefaultActions(); + updateTimer = new QTimer(this); + connect(updateTimer,SIGNAL(timeout()),this,SLOT(updateTimerTick())); +} + +void UASQuickView::addDefaultActions() +{ { QAction *action = new QAction(tr("latitude"),this); action->setCheckable(true); @@ -75,10 +82,8 @@ UASQuickView::UASQuickView(QWidget *parent) : this->layout()->addWidget(item); uasPropertyToLabelMap["distToWaypoint"] = item; } - - updateTimer = new QTimer(this); - connect(updateTimer,SIGNAL(timeout()),this,SLOT(updateTimerTick())); } + void UASQuickView::updateTimerTick() { for (int i=0;ideleteLater(); + } uasPropertyToLabelMap.clear(); + updateTimer->stop(); - this->actions().clear(); + foreach (QAction* i, this->actions()) + { + i->deleteLater(); + } } + // Update the UAS to point to the new one. this->uas = uas; + // And re-add the default actions. + addDefaultActions(); + // And connect the new one if it exists. if (this->uas) { diff --git a/src/ui/uas/UASQuickView.h b/src/ui/uas/UASQuickView.h index 513edc6cf..43537f472 100644 --- a/src/ui/uas/UASQuickView.h +++ b/src/ui/uas/UASQuickView.h @@ -14,6 +14,10 @@ class UASQuickView : public QWidget public: UASQuickView(QWidget *parent = 0); private: + /** + * Adds a default set of actions to the widget's menu. + */ + void addDefaultActions(); UASInterface *uas; QList uasPropertyList; QMap uasPropertyValueMap; -- 2.22.0