preferences: use std::string in struct preferences

This is a messy commit, because the "qPref" system relies
heavily on QString, which means lots of conversions between
the two worlds. Ultimately, I plan to base the preferences
system on std::string and only convert to QString when
pushing through Qt's property system or when writing into
Qt's settings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-13 22:59:32 +02:00 committed by bstoeger
parent 82fc9de40b
commit ccdd92aeb7
78 changed files with 645 additions and 694 deletions

View file

@ -4,12 +4,6 @@
#include <QSettings>
void qPrefPrivate::copy_txt(const char **name, const QString &string)
{
free((void *)*name);
*name = copy_qstring(string);
}
QString keyFromGroupAndName(QString group, QString name)
{
QString slash = (group.endsWith('/') || name.startsWith('/')) ? "" : "/";
@ -35,8 +29,19 @@ void qPrefPrivate::propSetValue(const QString &key, const QVariant &value, const
s.remove(key);
}
void qPrefPrivate::propSetValue(const QString &key, const std::string &value, const std::string &defaultValue)
{
propSetValue(key, QString::fromStdString(value), QString::fromStdString(defaultValue));
}
QVariant qPrefPrivate::propValue(const QString &key, const QVariant &defaultValue)
{
QSettings s;
return s.value(key, defaultValue);
}
QVariant qPrefPrivate::propValue(const QString &key, const std::string &defaultValue)
{
QSettings s;
return s.value(key, QString::fromStdString(defaultValue));
}