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:
parent
a9d2679e39
commit
3e9c819850
@ -45,8 +45,6 @@ UAVGadgetDecorator::UAVGadgetDecorator(IUAVGadget *gadget, QList<IUAVGadgetConfi
|
|||||||
foreach (IUAVGadgetConfiguration *config, *m_configurations)
|
foreach (IUAVGadgetConfiguration *config, *m_configurations)
|
||||||
m_toolbar->addItem(config->name());
|
m_toolbar->addItem(config->name());
|
||||||
connect(m_toolbar, SIGNAL(activated(int)), this, SLOT(loadConfiguration(int)));
|
connect(m_toolbar, SIGNAL(activated(int)), this, SLOT(loadConfiguration(int)));
|
||||||
// if (m_configurations->count() > 0)
|
|
||||||
// loadConfiguration(0);
|
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ UAVGadgetDecorator::~UAVGadgetDecorator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetDecorator::loadConfiguration(int index) {
|
void UAVGadgetDecorator::loadConfiguration(int index) {
|
||||||
IUAVGadgetConfiguration* config = m_configurations->at(index);
|
IUAVGadgetConfiguration *config = m_configurations->at(index);
|
||||||
loadConfiguration(config);
|
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)
|
if (config == m_activeConfiguration)
|
||||||
loadConfiguration(config);
|
loadConfiguration(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetDecorator::configurationAdded(IUAVGadgetConfiguration* config)
|
void UAVGadgetDecorator::configurationAdded(IUAVGadgetConfiguration *config)
|
||||||
{
|
{
|
||||||
if (config->classId() != classId())
|
if (config->classId() != classId())
|
||||||
return;
|
return;
|
||||||
@ -85,7 +83,7 @@ void UAVGadgetDecorator::configurationAdded(IUAVGadgetConfiguration* config)
|
|||||||
updateToolbar();
|
updateToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetDecorator::configurationToBeDeleted(IUAVGadgetConfiguration* config)
|
void UAVGadgetDecorator::configurationToBeDeleted(IUAVGadgetConfiguration *config)
|
||||||
{
|
{
|
||||||
if (config->classId() != classId())
|
if (config->classId() != classId())
|
||||||
return;
|
return;
|
||||||
@ -97,7 +95,7 @@ void UAVGadgetDecorator::configurationToBeDeleted(IUAVGadgetConfiguration* confi
|
|||||||
updateToolbar();
|
updateToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetDecorator::configurationNameChanged(IUAVGadgetConfiguration* config, QString oldName, QString newName)
|
void UAVGadgetDecorator::configurationNameChanged(IUAVGadgetConfiguration *config, QString oldName, QString newName)
|
||||||
{
|
{
|
||||||
if (config->classId() != classId())
|
if (config->classId() != classId())
|
||||||
return;
|
return;
|
||||||
@ -112,14 +110,14 @@ void UAVGadgetDecorator::updateToolbar()
|
|||||||
m_toolbar->setEnabled(m_toolbar->count() > 1);
|
m_toolbar->setEnabled(m_toolbar->count() > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
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* qSettings)
|
void UAVGadgetDecorator::restoreState(QSettings *qSettings)
|
||||||
{
|
{
|
||||||
QString configName = qSettings->value("activeConfiguration").toString();
|
QString configName = qSettings->value("activeConfiguration").toString();
|
||||||
foreach (IUAVGadgetConfiguration *config, *m_configurations) {
|
foreach (IUAVGadgetConfiguration *config, *m_configurations) {
|
||||||
|
@ -239,8 +239,9 @@ void UAVGadgetInstanceManager::createOptionsPages()
|
|||||||
m_pm->removeObject(m_optionsPages.takeLast());
|
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());
|
IUAVGadgetFactory *f = factory(config->classId());
|
||||||
IOptionsPage *p = f->createOptionsPage(config);
|
IOptionsPage *p = f->createOptionsPage(config);
|
||||||
if (p) {
|
if (p) {
|
||||||
@ -249,6 +250,14 @@ void UAVGadgetInstanceManager::createOptionsPages()
|
|||||||
m_optionsPages.append(page);
|
m_optionsPages.append(page);
|
||||||
m_pm->addObject(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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +230,9 @@ void UAVGadgetView::updateToolBar()
|
|||||||
|
|
||||||
void UAVGadgetView::listSelectionActivated(int index)
|
void UAVGadgetView::listSelectionActivated(int index)
|
||||||
{
|
{
|
||||||
|
if (index < 0 || index >= m_uavGadgetList->count())
|
||||||
|
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user