Commit e3fd9f7b authored by Ahmad Samir's avatar Ahmad Samir Committed by Tomaz Canabrava
Browse files

Make Profile::propertiesInfoList() static

And use std::string since we don't need a QString here, and at the end the
strings are printed as char* anyway.
parent d5822aed
Pipeline #188580 passed with stage
in 2 minutes and 31 seconds
......@@ -448,11 +448,10 @@ void Application::listAvailableProfiles()
void Application::listProfilePropertyInfo()
{
Profile::Ptr tempProfile = ProfileManager::instance()->defaultProfile();
const QStringList names = tempProfile->propertiesInfoList();
const std::vector<std::string> &properties = Profile::propertiesInfoList();
for (const QString &name : names) {
printf("%s\n", name.toLocal8Bit().constData());
for (const auto &prop : properties) {
printf("%s\n", prop.c_str());
}
}
......
......@@ -334,12 +334,17 @@ void Profile::registerProperty(const PropertyInfo &info)
PropertyInfoByName.insert(name.toLower(), info);
}
QStringList Profile::propertiesInfoList() const
// static
const std::vector<std::string> &Profile::propertiesInfoList()
{
QStringList list;
static std::vector<std::string> list;
if (!list.empty()) {
return list;
}
list.reserve(DefaultPropertyNames.size());
for (const PropertyInfo &info : DefaultPropertyNames) {
list.push_back(QLatin1String(info.name) + QLatin1String(" : ") + QLatin1String(QVariant(info.type).typeName()));
list.push_back(std::string(info.name) + " : " + QVariant(info.type).typeName());
}
return list;
}
......
......@@ -743,7 +743,7 @@ public:
/** Return a list of all properties names and their type
* (for use with -p option).
*/
QStringList propertiesInfoList() const;
static const std::vector<std::string> &propertiesInfoList();
/**
* Returns the element from the Property enum associated with the
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment