1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

OP-803 minor cleanups

This commit is contained in:
filnet 2013-01-20 17:32:55 +01:00
parent 1e3aeaf988
commit a9d2679e39
3 changed files with 10 additions and 12 deletions

View File

@ -115,17 +115,18 @@ void UAVGadgetDecorator::updateToolbar()
void UAVGadgetDecorator::saveState(QSettings* qSettings) void UAVGadgetDecorator::saveState(QSettings* qSettings)
{ {
if (m_activeConfiguration) { if (m_activeConfiguration) {
qSettings->setValue("activeConfiguration",m_activeConfiguration->name()); qSettings->setValue("activeConfiguration", m_activeConfiguration->name());
} }
} }
void UAVGadgetDecorator::restoreState(QSettings* qSetting) void UAVGadgetDecorator::restoreState(QSettings* qSettings)
{ {
QString configName = qSetting->value("activeConfiguration").toString(); QString configName = qSettings->value("activeConfiguration").toString();
foreach (IUAVGadgetConfiguration *config, *m_configurations) { foreach (IUAVGadgetConfiguration *config, *m_configurations) {
if (config->name() == configName) { if (config->name() == configName) {
m_activeConfiguration = config; m_activeConfiguration = config;
loadConfiguration(config); loadConfiguration(config);
break;
} }
} }
} }

View File

@ -230,14 +230,14 @@ void UAVGadgetView::updateToolBar()
void UAVGadgetView::listSelectionActivated(int index) void UAVGadgetView::listSelectionActivated(int index)
{ {
if (index < 0) // this could happen when called from SplitterOrView::restoreState()
index = m_defaultIndex;
QString classId = m_uavGadgetList->itemData(index).toString(); QString classId = m_uavGadgetList->itemData(index).toString();
if (m_uavGadget && (m_uavGadget->classId() == classId)) if (m_uavGadget && (m_uavGadget->classId() == classId))
return; return;
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager(); UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
IUAVGadget *gadgetToRemove = m_uavGadget;
IUAVGadget *gadget = im->createGadget(classId, this); IUAVGadget *gadget = im->createGadget(classId, this);
IUAVGadget *gadgetToRemove = m_uavGadget;
setGadget(gadget); setGadget(gadget);
m_uavGadgetManager->setCurrentGadget(gadget); m_uavGadgetManager->setCurrentGadget(gadget);
im->removeGadget(gadgetToRemove); im->removeGadget(gadgetToRemove);
@ -265,15 +265,12 @@ void UAVGadgetView::saveState(QSettings* qSettings)
void UAVGadgetView::restoreState(QSettings* qSettings) void UAVGadgetView::restoreState(QSettings* qSettings)
{ {
QString classId = qSettings->value("classId").toString(); QString classId = qSettings->value("classId").toString();
int index = indexOfClassId(classId); int index = indexOfClassId(classId);
if (index < 0) { if (index < 0) {
index = m_defaultIndex; index = m_defaultIndex;
} }
classId = m_uavGadgetList->itemData(index).toString(); classId = m_uavGadgetList->itemData(index).toString();
IUAVGadget *newGadget; IUAVGadget *newGadget;
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager(); UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
if(qSettings->childGroups().contains("gadget")) { if(qSettings->childGroups().contains("gadget")) {

View File

@ -67,15 +67,15 @@ public:
UAVGadgetView(UAVGadgetManager *uavGadgetManager, IUAVGadget *uavGadget = 0, QWidget *parent = 0); UAVGadgetView(UAVGadgetManager *uavGadgetManager, IUAVGadget *uavGadget = 0, QWidget *parent = 0);
virtual ~UAVGadgetView(); virtual ~UAVGadgetView();
void removeGadget();
IUAVGadget *gadget() const; IUAVGadget *gadget() const;
void setGadget(IUAVGadget *uavGadget); void setGadget(IUAVGadget *uavGadget);
bool hasGadget(IUAVGadget *uavGadget) const; bool hasGadget(IUAVGadget *uavGadget) const;
void removeGadget();
void showToolbar(bool show); void showToolbar(bool show);
void saveState(QSettings* qSettings); void saveState(QSettings *qSettings);
void restoreState(QSettings* qSettings); void restoreState(QSettings *qSettings);
public slots: public slots:
void closeView(); void closeView();