1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

GCS/coreplugin: Change deletion of configurations to not take effect until Apply or Ok buttons are clicked.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@392 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
ephy 2010-03-26 16:10:58 +00:00 committed by ephy
parent ad0382215f
commit 59254ae382
4 changed files with 20 additions and 15 deletions

View File

@ -164,9 +164,6 @@ void SettingsDialog::deletePage()
{
QTreeWidgetItem *item = pageTree->currentItem();
item->parent()->removeChild(item);
PageData data = item->data(0, Qt::UserRole).value<PageData>();
int index = data.index;
m_deletedPageIndices.append(index);
pageSelected();
}
@ -218,7 +215,6 @@ void SettingsDialog::accept()
{
m_applied = true;
foreach (IOptionsPage *page, m_pages) {
if (!m_deletedPageIndices.contains(m_pages.indexOf(page)))
page->apply();
page->finish();
}
@ -235,7 +231,6 @@ void SettingsDialog::reject()
void SettingsDialog::apply()
{
foreach (IOptionsPage *page, m_pages) {
if (!m_deletedPageIndices.contains(m_pages.indexOf(page)))
page->apply();
}
m_applied = true;

View File

@ -78,7 +78,6 @@ private:
bool m_applied;
QString m_currentCategory;
QString m_currentPage;
QList<int> m_deletedPageIndices;
};
} // namespace Internal

View File

@ -163,6 +163,7 @@ bool UAVGadgetInstanceManager::canDeleteConfiguration(IUAVGadgetConfiguration *c
void UAVGadgetInstanceManager::deleteConfiguration(IUAVGadgetConfiguration *config)
{
m_provisionalDeletes.append(config);
if (m_provisionalConfigs.contains(config)) {
int i = m_provisionalConfigs.indexOf(config);
m_provisionalConfigs.removeAt(i);
@ -171,13 +172,7 @@ void UAVGadgetInstanceManager::deleteConfiguration(IUAVGadgetConfiguration *con
m_takenNames[config->classId()].removeAt(j);
m_settingsDialog->deletePage();
} else if (m_configurations.contains(config)) {
emit configurationToBeDeleted(config);
int i = m_configurations.indexOf(config);
m_provisionalConfigs.removeAt(i);
m_pm->removeObject(m_optionsPages.at(i));
m_optionsPages.removeAt(i);//TODO delete
m_settingsDialog->deletePage();
m_configurations.removeAt(i);
}
configurationNameEdited("", false);
}
@ -220,6 +215,19 @@ QString UAVGadgetInstanceManager::suggestName(QString classId, QString name)
void UAVGadgetInstanceManager::applyChanges(IUAVGadgetConfiguration *config)
{
if (m_provisionalDeletes.contains(config)) {
m_provisionalDeletes.removeAt(m_provisionalDeletes.indexOf(config));
int i = m_configurations.indexOf(config);
if (i >= 0) {
emit configurationToBeDeleted(config);
int j = m_takenNames[config->classId()].indexOf(config->name());
m_takenNames[config->classId()].removeAt(j);
m_pm->removeObject(m_optionsPages.at(i));
m_configurations.removeAt(i);
m_optionsPages.removeAt(i);//TODO delete
}
return;
}
if (config->provisionalName() != config->name()) {
emit configurationNameChanged(config->name(), config->provisionalName());
config->setName(config->provisionalName());
@ -228,10 +236,12 @@ void UAVGadgetInstanceManager::applyChanges(IUAVGadgetConfiguration *config)
emit configurationChanged(config);
} else if (m_provisionalConfigs.contains(config)) {
emit configurationAdded(config);
int i = m_provisionalConfigs.indexOf(config);
IOptionsPage *page = m_provisionalOptionsPages.at(i);
m_configurations.append(config);
IUAVGadgetFactory *f = factory(config->classId());
IOptionsPage *page = f->createOptionsPage(config);
m_optionsPages.append(page);
m_provisionalConfigs.removeAt(i);
m_provisionalOptionsPages.removeAt(i);
m_pm->addObject(page);
}
}
@ -273,13 +283,13 @@ void UAVGadgetInstanceManager::settingsDialogRemoved()
{
m_takenNames.clear();
m_provisionalConfigs.clear();
m_provisionalDeletes.clear();
m_provisionalOptionsPages.clear(); //TODO delete
foreach (IUAVGadgetConfiguration *config, m_configurations)
config->setProvisionalName(config->name());
m_settingsDialog = 0;
}
QStringList UAVGadgetInstanceManager::configurationNames(QString classId) const
{
QStringList names;

View File

@ -88,6 +88,7 @@ private:
QMap<QString, QString> m_classIds;
QMap<QString, QStringList> m_takenNames;
QList<IUAVGadgetConfiguration*> m_provisionalConfigs;
QList<IUAVGadgetConfiguration*> m_provisionalDeletes;
QList<IOptionsPage*> m_provisionalOptionsPages;
Core::Internal::SettingsDialog *m_settingsDialog;
ExtensionSystem::PluginManager *m_pm;