From 481005cc69a7e290eb7853111105d4d2f0a3614c Mon Sep 17 00:00:00 2001 From: filnet Date: Wed, 16 Jan 2013 22:30:16 +0100 Subject: [PATCH] OP-803 transparent refactoring - moved specific save/restore code from SplitterOrView to UAVGadgetView and made some methods private --- .../uavgadgetmanager/splitterorview.cpp | 15 ++----------- .../uavgadgetmanager/uavgadgetview.cpp | 21 +++++++++++++++++++ .../uavgadgetmanager/uavgadgetview.h | 8 +++++-- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/splitterorview.cpp b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/splitterorview.cpp index 183ffa185..2a3a02f64 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/splitterorview.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/splitterorview.cpp @@ -347,11 +347,7 @@ void SplitterOrView::saveState(QSettings* qSettings) const { static_cast(m_splitter->widget(1))->saveState(qSettings); qSettings->endGroup(); } else if (gadget()) { - qSettings->setValue("type", "uavGadget"); - qSettings->setValue("classId", gadget()->classId()); - qSettings->beginGroup("gadget"); - gadget()->saveState(qSettings); - qSettings->endGroup(); + m_view->saveState(qSettings); } } @@ -374,13 +370,6 @@ void SplitterOrView::restoreState(QSettings* qSettings) static_cast(m_splitter->widget(1))->restoreState(qSettings); qSettings->endGroup(); } else if (mode == "uavGadget") { - QString classId = qSettings->value("classId").toString(); - int index = m_view->indexOfClassId(classId); - m_view->listSelectionActivated(index); - if(qSettings->childGroups().contains("gadget")) { - qSettings->beginGroup("gadget"); - gadget()->restoreState(qSettings); - qSettings->endGroup(); - } + m_view->restoreState(qSettings); } } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/uavgadgetview.cpp b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/uavgadgetview.cpp index 13b2b3062..6deb3adc9 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/uavgadgetview.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/uavgadgetview.cpp @@ -252,3 +252,24 @@ void UAVGadgetView::currentGadgetChanged(IUAVGadget *gadget) { m_activeLabel->setVisible(m_uavGadget == gadget); } + +void UAVGadgetView::saveState(QSettings* qSettings) +{ + qSettings->setValue("type", "uavGadget"); + qSettings->setValue("classId", gadget()->classId()); + qSettings->beginGroup("gadget"); + gadget()->saveState(qSettings); + qSettings->endGroup(); +} + +void UAVGadgetView::restoreState(QSettings* qSettings) +{ + QString classId = qSettings->value("classId").toString(); + int index = indexOfClassId(classId); + listSelectionActivated(index); + if(qSettings->childGroups().contains("gadget")) { + qSettings->beginGroup("gadget"); + gadget()->restoreState(qSettings); + qSettings->endGroup(); + } +} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/uavgadgetview.h b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/uavgadgetview.h index 494f456f0..2f2a12992 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/uavgadgetview.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetmanager/uavgadgetview.h @@ -71,17 +71,21 @@ public: IUAVGadget *gadget() const; void setGadget(IUAVGadget *uavGadget); bool hasGadget(IUAVGadget *uavGadget) const; - int indexOfClassId(QString classId); + void showToolbar(bool show); + void saveState(QSettings* qSettings); + void restoreState(QSettings* qSettings); + public slots: void closeView(); - void listSelectionActivated(int index); private slots: + void listSelectionActivated(int index); void currentGadgetChanged(IUAVGadget *gadget); private: + int indexOfClassId(QString classId); void updateToolBar(); QPointer m_uavGadgetManager;