[libcalamares] Start making InstanceDescription a stronger type

- Replace a map-of-strings with a class type.
- For now, doesn't compile.
- Intention is to construct from a YAML / QVariant from the
  *instances* list in `settings.conf`.
This commit is contained in:
Adriaan de Groot 2020-03-13 02:41:42 +01:00
parent 3897bd54df
commit 0e68013bb3
2 changed files with 18 additions and 19 deletions

View File

@ -71,6 +71,10 @@ requireBool( const YAML::Node& config, const char* key, bool d )
namespace Calamares namespace Calamares
{ {
InstanceDescription::InstanceDescription( const QVariantMap& m )
{
}
Settings* Settings::s_instance = nullptr; Settings* Settings::s_instance = nullptr;
Settings* Settings*
@ -134,17 +138,7 @@ interpretInstances( const YAML::Node& node, Settings::InstanceDescriptionList& c
{ {
continue; continue;
} }
QVariantMap instancesVListItemMap = instancesVListItem.toMap(); customInstances.append( InstanceDescription( instancesVListItem.toMap() ) );
Settings::InstanceDescription instanceMap;
for ( auto it = instancesVListItemMap.constBegin(); it != instancesVListItemMap.constEnd(); ++it )
{
if ( it.value().type() != QVariant::String )
{
continue;
}
instanceMap.insert( it.key(), it.value().toString() );
}
customInstances.append( instanceMap );
} }
} }
} }

View File

@ -32,6 +32,12 @@
namespace Calamares namespace Calamares
{ {
class DLLEXPORT InstanceDescription
{
public:
InstanceDescription( const QVariantMap& );
};
class DLLEXPORT Settings : public QObject class DLLEXPORT Settings : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -45,7 +51,6 @@ public:
QStringList modulesSearchPaths() const; QStringList modulesSearchPaths() const;
using InstanceDescription = QMap< QString, QString >;
using InstanceDescriptionList = QList< InstanceDescription >; using InstanceDescriptionList = QList< InstanceDescription >;
InstanceDescriptionList customModuleInstances() const; InstanceDescriptionList customModuleInstances() const;