1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-803 more cleanups

This commit is contained in:
filnet 2013-01-28 23:13:47 +01:00
parent a9d2679e39
commit 3e9c819850
3 changed files with 21 additions and 11 deletions

View File

@ -45,8 +45,6 @@ UAVGadgetDecorator::UAVGadgetDecorator(IUAVGadget *gadget, QList<IUAVGadgetConfi
foreach (IUAVGadgetConfiguration *config, *m_configurations)
m_toolbar->addItem(config->name());
connect(m_toolbar, SIGNAL(activated(int)), this, SLOT(loadConfiguration(int)));
// if (m_configurations->count() > 0)
// loadConfiguration(0);
updateToolbar();
}
@ -57,7 +55,7 @@ UAVGadgetDecorator::~UAVGadgetDecorator()
}
void UAVGadgetDecorator::loadConfiguration(int index) {
IUAVGadgetConfiguration* config = m_configurations->at(index);
IUAVGadgetConfiguration *config = m_configurations->at(index);
loadConfiguration(config);
}
@ -70,13 +68,13 @@ void UAVGadgetDecorator::loadConfiguration(IUAVGadgetConfiguration *config)
}
void UAVGadgetDecorator::configurationChanged(IUAVGadgetConfiguration* config)
void UAVGadgetDecorator::configurationChanged(IUAVGadgetConfiguration *config)
{
if (config == m_activeConfiguration)
loadConfiguration(config);
}
void UAVGadgetDecorator::configurationAdded(IUAVGadgetConfiguration* config)
void UAVGadgetDecorator::configurationAdded(IUAVGadgetConfiguration *config)
{
if (config->classId() != classId())
return;
@ -85,7 +83,7 @@ void UAVGadgetDecorator::configurationAdded(IUAVGadgetConfiguration* config)
updateToolbar();
}
void UAVGadgetDecorator::configurationToBeDeleted(IUAVGadgetConfiguration* config)
void UAVGadgetDecorator::configurationToBeDeleted(IUAVGadgetConfiguration *config)
{
if (config->classId() != classId())
return;
@ -97,7 +95,7 @@ void UAVGadgetDecorator::configurationToBeDeleted(IUAVGadgetConfiguration* confi
updateToolbar();
}
void UAVGadgetDecorator::configurationNameChanged(IUAVGadgetConfiguration* config, QString oldName, QString newName)
void UAVGadgetDecorator::configurationNameChanged(IUAVGadgetConfiguration *config, QString oldName, QString newName)
{
if (config->classId() != classId())
return;
@ -112,14 +110,14 @@ void UAVGadgetDecorator::updateToolbar()
m_toolbar->setEnabled(m_toolbar->count() > 1);
}
void UAVGadgetDecorator::saveState(QSettings* qSettings)
void UAVGadgetDecorator::saveState(QSettings *qSettings)
{
if (m_activeConfiguration) {
qSettings->setValue("activeConfiguration", m_activeConfiguration->name());
}
}
void UAVGadgetDecorator::restoreState(QSettings* qSettings)
void UAVGadgetDecorator::restoreState(QSettings *qSettings)
{
QString configName = qSettings->value("activeConfiguration").toString();
foreach (IUAVGadgetConfiguration *config, *m_configurations) {

View File

@ -239,8 +239,9 @@ void UAVGadgetInstanceManager::createOptionsPages()
m_pm->removeObject(m_optionsPages.takeLast());
}
foreach (IUAVGadgetConfiguration *config, m_configurations)
{
QMutableListIterator<IUAVGadgetConfiguration*> ite(m_configurations);
while (ite.hasNext()) {
IUAVGadgetConfiguration *config = ite.next();
IUAVGadgetFactory *f = factory(config->classId());
IOptionsPage *p = f->createOptionsPage(config);
if (p) {
@ -249,6 +250,14 @@ void UAVGadgetInstanceManager::createOptionsPages()
m_optionsPages.append(page);
m_pm->addObject(page);
}
else {
qWarning()
<< "UAVGadgetInstanceManager::createOptionsPages - failed to create options page for configuration "
+ config->classId() + ":" + config->name() + ", configuration will be removed.";
// The m_optionsPages list and m_configurations list must be in synch otherwise nasty issues happen later
// so if we fail to create an options page we must remove the associated configuration
ite.remove();
}
}
}

View File

@ -230,6 +230,9 @@ void UAVGadgetView::updateToolBar()
void UAVGadgetView::listSelectionActivated(int index)
{
if (index < 0 || index >= m_uavGadgetList->count())
index = m_defaultIndex;
QString classId = m_uavGadgetList->itemData(index).toString();
if (m_uavGadget && (m_uavGadget->classId() == classId))
return;