PythonHelper: Add support for bool.

Convert Python bool type from/to C++/QVariant bool (QVariant::Bool) in
PythonHelper::variantToPyObject and PythonHelper::variantFromPyObject.

This fixes the "override" option and any booleans in the "defaults" list
in grubcfg.conf.
This commit is contained in:
Kevin Kofler 2014-11-18 05:34:01 +01:00
parent 1499963920
commit 00604a8bca

View File

@ -53,6 +53,9 @@ variantToPyObject( const QVariant& variant )
case QVariant::String:
return bp::object( variant.toString().toStdString() );
case QVariant::Bool:
return bp::object( variant.toBool() );
default:
return bp::object();
}
@ -78,6 +81,9 @@ variantFromPyObject( const boost::python::object& pyObject )
else if ( pyType == "str" )
return QVariant( QString::fromStdString( bp::extract< std::string >( pyObject ) ) );
else if ( pyType == "bool" )
return QVariant( bp::extract< bool >( pyObject ) );
else
return QVariant();
}