1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

GCS: Removed last 'binary' config reading support, for layout/splitter settings.

Again, use the previous version to convert old config files if needed :)


git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1812 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
cranphin 2010-09-30 20:55:15 +00:00 committed by cranphin
parent b418fe18bf
commit 9c705aedf1
6 changed files with 3 additions and 118 deletions

View File

@ -129,16 +129,3 @@ void UAVGadgetDecorator::restoreState(QSettings* qSetting)
}
}
}
void UAVGadgetDecorator::restoreState(QByteArray state)
{
QDataStream stream(state);
QByteArray configName;
stream >> configName;
foreach (IUAVGadgetConfiguration *config, *m_configurations) {
if (config->name() == configName) {
m_activeConfiguration = config;
loadConfiguration(config);
}
}
}

View File

@ -45,7 +45,6 @@ public:
IUAVGadgetConfiguration *activeConfiguration() { return m_activeConfiguration; }
void loadConfiguration(IUAVGadgetConfiguration *config);
void saveState(QSettings* qSettings);
void restoreState(QByteArray state);
void restoreState(QSettings* qSettings);
public slots:
void configurationChanged(IUAVGadgetConfiguration* config);

View File

@ -435,38 +435,3 @@ void SplitterOrView::restoreState(QSettings* qSettings)
}
}
}
void SplitterOrView::restoreState(const QByteArray &state)
{
QDataStream stream(state);
QByteArray mode;
stream >> mode;
if (mode == "splitter") {
qint32 orientation;
QByteArray splitter, first, second;
stream >> orientation >> splitter >> first >> second;
split((Qt::Orientation)orientation);
m_splitter->restoreState(splitter);
// TODO: Lots of ugly, but this whole method should dissapear ASAP,
// It's here only for temporary backwards compatability.
m_sizes.clear();
QDataStream stream(&splitter, QIODevice::ReadOnly);
qint32 marker;
qint32 v;
stream >> marker;
stream >> v;
stream >> m_sizes;
static_cast<SplitterOrView*>(m_splitter->widget(0))->restoreState(first);
static_cast<SplitterOrView*>(m_splitter->widget(1))->restoreState(second);
} else if (mode == "uavGadget") {
QString classId;
QByteArray uavGadgetState;
stream >> classId >> uavGadgetState;
int index = m_view->indexOfClassId(classId);
m_view->listSelectionActivated(index);
gadget()->restoreState(uavGadgetState);
}
}

View File

@ -61,7 +61,6 @@ public:
UAVGadgetView *takeView();
void saveState(QSettings*) const;
void restoreState(const QByteArray &);
void restoreState(QSettings*);
SplitterOrView *findView(Core::IUAVGadget *uavGadget);

View File

@ -465,55 +465,13 @@ bool UAVGadgetManager::restoreState(QSettings* qSettings)
return true;
}
bool UAVGadgetManager::restoreState(const QByteArray &state)
{
removeAllSplits();
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
IUAVGadget *gadget = m_d->m_splitterOrView->view()->gadget();
emptyView(m_d->m_splitterOrView->view());
im->removeGadget(gadget);
QDataStream stream(state);
QByteArray version;
stream >> version;
if (version != "UAVGadgetManagerV1")
return false;
stream >> m_showToolbars;
QApplication::setOverrideCursor(Qt::WaitCursor);
QByteArray splitterstates;
stream >> splitterstates;
m_d->m_splitterOrView->restoreState(splitterstates);
QApplication::restoreOverrideCursor();
return true;
}
void UAVGadgetManager::saveSettings(QSettings *qs)
{
qs->beginGroup("UAVGadgetManager");
qs->beginGroup(m_uavGadgetMode->uniqueModeName());
QString defaultUAVGadgetManagerKey = "DefaultSettings";
QString uavGadgetManagerKey = "Settings";
// The default group can be done in a better way,
// remove them for now. Since we no longer have two
// possible groups, we can remove the non default one too.
// TODO: Remove this code, and support for reading default group.
if (qs->childKeys().contains(defaultUAVGadgetManagerKey) ||
qs->childGroups().contains(defaultUAVGadgetManagerKey)) {
qs->remove(defaultUAVGadgetManagerKey);
}
if (qs->allKeys().contains(uavGadgetManagerKey) ||
qs->childGroups().contains(uavGadgetManagerKey)) {
qs->remove(uavGadgetManagerKey);
}
// Make sure the old tree is wiped.
qs->remove("");
// Do actual saving
saveState(qs);
@ -536,29 +494,7 @@ void UAVGadgetManager::readSettings(QSettings *qs)
}
qs->beginGroup(m_uavGadgetMode->uniqueModeName());
QString defaultUAVGadgetManagerKey = "DefaultSettings";
QString uavGadgetManagerKey = "Settings";
if (qs->childGroups().contains(uavGadgetManagerKey)) {
// TODO: Remove.
qs->beginGroup(uavGadgetManagerKey);
restoreState(qs);
qs->endGroup();
} else if (qs->childGroups().contains(defaultUAVGadgetManagerKey)) {
// TODO: Remove.
qs->beginGroup(defaultUAVGadgetManagerKey);
restoreState(qs);
qs->endGroup();
} else if (qs->contains(uavGadgetManagerKey)) {
// TODO: Remove.
restoreState(QByteArray::fromBase64(qs->value(uavGadgetManagerKey).toByteArray()));
} else if (qs->contains(defaultUAVGadgetManagerKey)) {
// TODO: Remove.
restoreState(QByteArray::fromBase64(qs->value(defaultUAVGadgetManagerKey).toByteArray()));
} else {
// TODO: Make this the only way of loading.
restoreState(qs);
}
restoreState(qs);
showToolbars(m_showToolbars);
updateActions();

View File

@ -97,7 +97,6 @@ public:
IUAVGadget *currentGadget() const;
void saveState(QSettings*) const;
bool restoreState(const QByteArray &state);
bool restoreState(QSettings* qSettings);
void saveSettings(QSettings* qs);