mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08: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);
|
||||
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<SplitterOrView*>(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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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<UAVGadgetManager> m_uavGadgetManager;
|
||||
|
Loading…
Reference in New Issue
Block a user