forked from qt-creator/qt-creator
CMake: Simplify CMakeConfigItem::toBool() use
Change-Id: I60120a152174b7c3751b99ac92d31bdb9c3ab1d9 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -186,11 +186,11 @@ QString CMakeConfigItem::typeToTypeString(const CMakeConfigItem::Type t)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::optional<bool> CMakeConfigItem::toBool(const QByteArray &value)
|
Utils::optional<bool> CMakeConfigItem::toBool(const QString &value)
|
||||||
{
|
{
|
||||||
// Taken from CMakes if(<constant>) documentation:
|
// Taken from CMakes if(<constant>) documentation:
|
||||||
// "Named boolean constants are case-insensitive."
|
// "Named boolean constants are case-insensitive."
|
||||||
const QString v = QString::fromUtf8(value).toUpper();
|
const QString v = value.toUpper();
|
||||||
|
|
||||||
bool isInt = false;
|
bool isInt = false;
|
||||||
v.toInt(&isInt);
|
v.toInt(&isInt);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
static QStringList cmakeSplitValue(const QString &in, bool keepEmpty = false);
|
static QStringList cmakeSplitValue(const QString &in, bool keepEmpty = false);
|
||||||
static Type typeStringToType(const QByteArray &typeString);
|
static Type typeStringToType(const QByteArray &typeString);
|
||||||
static QString typeToTypeString(const Type t);
|
static QString typeToTypeString(const Type t);
|
||||||
static Utils::optional<bool> toBool(const QByteArray &value);
|
static Utils::optional<bool> toBool(const QString &value);
|
||||||
bool isNull() const { return key.isEmpty(); }
|
bool isNull() const { return key.isEmpty(); }
|
||||||
|
|
||||||
QString expandedValue(const ProjectExplorer::Kit *k) const;
|
QString expandedValue(const ProjectExplorer::Kit *k) const;
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ QVariant ConfigModelTreeItem::data(int column, int role) const
|
|||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
const QString value = currentValue();
|
const QString value = currentValue();
|
||||||
const auto boolValue = CMakeConfigItem::toBool(value.toUtf8());
|
const auto boolValue = CMakeConfigItem::toBool(value);
|
||||||
const bool isTrue = boolValue.has_value() && boolValue.value();
|
const bool isTrue = boolValue.has_value() && boolValue.value();
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ static CMakeConfig readCacheFile(const FilePath &cacheFile, QString &errorMessag
|
|||||||
const QJsonObject prop = v.toObject();
|
const QJsonObject prop = v.toObject();
|
||||||
auto nv = nameValue(prop);
|
auto nv = nameValue(prop);
|
||||||
if (nv.first == "ADVANCED") {
|
if (nv.first == "ADVANCED") {
|
||||||
const auto boolValue = CMakeConfigItem::toBool(nv.second.toUtf8());
|
const auto boolValue = CMakeConfigItem::toBool(nv.second);
|
||||||
item.isAdvanced = boolValue.has_value() && boolValue.value();
|
item.isAdvanced = boolValue.has_value() && boolValue.value();
|
||||||
} else if (nv.first == "HELPSTRING") {
|
} else if (nv.first == "HELPSTRING") {
|
||||||
item.documentation = nv.second.toUtf8();
|
item.documentation = nv.second.toUtf8();
|
||||||
|
|||||||
Reference in New Issue
Block a user