mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-803 transparent refactoring - moved specific save/restore code
from SplitterOrView to UAVGadgetView and made some methods private
This commit is contained in:
parent
a45578c250
commit
481005cc69
@ -347,11 +347,7 @@ void SplitterOrView::saveState(QSettings* qSettings) const {
|
|||||||
static_cast<SplitterOrView*>(m_splitter->widget(1))->saveState(qSettings);
|
static_cast<SplitterOrView*>(m_splitter->widget(1))->saveState(qSettings);
|
||||||
qSettings->endGroup();
|
qSettings->endGroup();
|
||||||
} else if (gadget()) {
|
} else if (gadget()) {
|
||||||
qSettings->setValue("type", "uavGadget");
|
m_view->saveState(qSettings);
|
||||||
qSettings->setValue("classId", gadget()->classId());
|
|
||||||
qSettings->beginGroup("gadget");
|
|
||||||
gadget()->saveState(qSettings);
|
|
||||||
qSettings->endGroup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,13 +370,6 @@ void SplitterOrView::restoreState(QSettings* qSettings)
|
|||||||
static_cast<SplitterOrView*>(m_splitter->widget(1))->restoreState(qSettings);
|
static_cast<SplitterOrView*>(m_splitter->widget(1))->restoreState(qSettings);
|
||||||
qSettings->endGroup();
|
qSettings->endGroup();
|
||||||
} else if (mode == "uavGadget") {
|
} else if (mode == "uavGadget") {
|
||||||
QString classId = qSettings->value("classId").toString();
|
m_view->restoreState(qSettings);
|
||||||
int index = m_view->indexOfClassId(classId);
|
|
||||||
m_view->listSelectionActivated(index);
|
|
||||||
if(qSettings->childGroups().contains("gadget")) {
|
|
||||||
qSettings->beginGroup("gadget");
|
|
||||||
gadget()->restoreState(qSettings);
|
|
||||||
qSettings->endGroup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,3 +252,24 @@ void UAVGadgetView::currentGadgetChanged(IUAVGadget *gadget)
|
|||||||
{
|
{
|
||||||
m_activeLabel->setVisible(m_uavGadget == 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -71,17 +71,21 @@ public:
|
|||||||
IUAVGadget *gadget() const;
|
IUAVGadget *gadget() const;
|
||||||
void setGadget(IUAVGadget *uavGadget);
|
void setGadget(IUAVGadget *uavGadget);
|
||||||
bool hasGadget(IUAVGadget *uavGadget) const;
|
bool hasGadget(IUAVGadget *uavGadget) const;
|
||||||
int indexOfClassId(QString classId);
|
|
||||||
void showToolbar(bool show);
|
void showToolbar(bool show);
|
||||||
|
|
||||||
|
void saveState(QSettings* qSettings);
|
||||||
|
void restoreState(QSettings* qSettings);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void closeView();
|
void closeView();
|
||||||
void listSelectionActivated(int index);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void listSelectionActivated(int index);
|
||||||
void currentGadgetChanged(IUAVGadget *gadget);
|
void currentGadgetChanged(IUAVGadget *gadget);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int indexOfClassId(QString classId);
|
||||||
void updateToolBar();
|
void updateToolBar();
|
||||||
|
|
||||||
QPointer<UAVGadgetManager> m_uavGadgetManager;
|
QPointer<UAVGadgetManager> m_uavGadgetManager;
|
||||||
|
Loading…
Reference in New Issue
Block a user