Commit 8f2e64f1 authored by Rafał Malinowski's avatar Rafał Malinowski

fixup! configuration: remove more unused methods

Signed-off-by: Rafał Malinowski's avatarRafał Malinowski <rafal.przemyslaw.malinowski@gmail.com>
parent 869f68b1
......@@ -207,70 +207,11 @@ QString PlainConfigFile::getEntry(const QString &group, const QString &name, boo
return QString();
}
void PlainConfigFile::writeEntry(const QString &group, const QString &name, const QVariant &value)
{
changeEntry(group, name, value.toString());
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const QString &value)
{
changeEntry(group, name, value);
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const char *value)
{
changeEntry(group, name, QString::fromLocal8Bit(value));
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const int value)
{
changeEntry(group, name, QString::number(value));
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const double value)
{
changeEntry(group, name, QString::number(value, 'f'));
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const bool value)
{
changeEntry(group, name, value ? "true" : "false");
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const QRect &value)
{
changeEntry(group, name, rectToString(value));
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const QSize &value)
{
changeEntry(group, name, QString("%1,%2").arg(value.width()).arg(value.height()));
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const QColor &value)
{
changeEntry(group, name, value.name());
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const QFont &value)
{
changeEntry(group, name, value.family() + ',' + QString::number(value.pointSize()));
}
void PlainConfigFile::writeEntry(const QString &group,const QString &name, const QPoint &value)
{
changeEntry(group, name, QString("%1,%2").arg(value.x()).arg(value.y()));
}
template <class T>
T PlainConfigFile::readEntry(const QString &group, const QString &name, const T &def )
{
QVariant string = QVariant::fromValue(getEntry(group, name));
if (string.canConvert<T>())
return string.value<T>();
return def;
}
QString PlainConfigFile::readEntry(const QString &group,const QString &name, const QString &def)
{
QString string = getEntry(group, name);
......@@ -279,42 +220,6 @@ QString PlainConfigFile::readEntry(const QString &group,const QString &name, con
return string;
}
unsigned int PlainConfigFile::readUnsignedNumEntry(const QString &group,const QString &name, unsigned int def)
{
bool ok;
QString string = getEntry(group, name);
if (string.isNull())
return def;
unsigned int num = string.toUInt(&ok);
if (!ok)
return def;
return num;
}
int PlainConfigFile::readNumEntry(const QString &group,const QString &name, int def)
{
bool ok;
QString string = getEntry(group, name);
if (string.isNull())
return def;
int num = string.toInt(&ok);
if (!ok)
return def;
return num;
}
double PlainConfigFile::readDoubleNumEntry(const QString &group,const QString &name, double def)
{
bool ok;
QString string = getEntry(group, name);
if (string.isNull())
return def;
double num = string.toDouble(&ok);
if (!ok)
return def;
return num;
}
bool PlainConfigFile::readBoolEntry(const QString &group,const QString &name, bool def)
{
QString string = getEntry(group, name);
......@@ -323,151 +228,6 @@ bool PlainConfigFile::readBoolEntry(const QString &group,const QString &name, bo
return string=="true";
}
QRect PlainConfigFile::readRectEntry(const QString &group,const QString &name, const QRect *def)
{
return stringToRect(getEntry(group, name), def);
}
QSize PlainConfigFile::readSizeEntry(const QString &group,const QString &name, const QSize *def)
{
QString string = getEntry(group, name);
QStringList stringlist;
QSize size(0,0);
int w, h;
bool ok;
if (string.isNull())
return def ? *def : size;
stringlist = string.split(',', QString::SkipEmptyParts);
if (stringlist.count() != 2)
return def ? *def : size;
w = stringlist.at(0).toInt(&ok);
if (!ok)
return def ? *def : size;
h = stringlist.at(1).toInt(&ok);
if (!ok)
return def ? *def : size;
size.setWidth(w);
size.setHeight(h);
return size;
}
QColor PlainConfigFile::readColorEntry(const QString &group,const QString &name, const QColor *def)
{
QString str = getEntry(group, name);
if (str.isNull())
return def ? *def : QColor(0, 0, 0);
else
return QColor(str);
}
QFont PlainConfigFile::readFontEntry(const QString &group,const QString &name, const QFont *def)
{
QString string = getEntry(group, name);
QStringList stringlist;
QFont font;
bool ok;
if (string.isNull())
return def ? *def : QApplication::font();
stringlist = string.split(',', QString::SkipEmptyParts);
if (stringlist.count() < 2)
return def ? *def : QApplication::font();
font.setFamily(stringlist.at(0));
font.setPointSize(stringlist.at(1).toInt(&ok));
if (!ok)
return def ? *def : QApplication::font();
return font;
}
void PlainConfigFile::removeVariable(const QString &group, const QString &name)
{
if (activeGroupName != group)
changeActiveGroup(group);
if (activeGroup.contains(name))
activeGroup.remove(name);
}
QPoint PlainConfigFile::readPointEntry(const QString &group,const QString &name, const QPoint *def)
{
QString string = getEntry(group, name);
QStringList stringlist;
QPoint point(0,0);
int x, y;
bool ok;
if (string.isNull())
return def ? *def : point;
stringlist = string.split(',', QString::SkipEmptyParts);
if (stringlist.count() != 2)
return def ? *def : point;
x = stringlist.at(0).toInt(&ok);
if (!ok)
return def ? *def : point;
y = stringlist.at(1).toInt(&ok);
if (!ok)
return def ? *def : point;
point.setX(x);
point.setY(y);
return point;
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const QString &defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const char *defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const int defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const double defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const bool defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const QRect &defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const QSize &defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const QColor &defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const QFont &defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
void PlainConfigFile::addVariable(const QString &group, const QString &name, const QPoint &defvalue)
{
if (getEntry(group, name).isEmpty())
writeEntry(group,name,defvalue);
}
ConfigFile::ConfigFile(const QString &filename) : filename(filename)
{
}
......
......@@ -67,44 +67,10 @@ public:
QStringList getGroupList() const;
void writeEntry(const QString &group, const QString &name, const QVariant &value);
void writeEntry(const QString &group,const QString &name, const QString &value);
void writeEntry(const QString &group,const QString &name, const char *value);
void writeEntry(const QString &group, const QString &name, const int value);
void writeEntry(const QString &group, const QString &name, const double value);
void writeEntry(const QString &group,const QString &name, const bool value);
void writeEntry(const QString &group,const QString &name, const QRect &value);
void writeEntry(const QString &group, const QString &name, const QSize &value);
void writeEntry(const QString &group, const QString &name, const QColor &value);
void writeEntry(const QString &group, const QString &name, const QFont &value);
void writeEntry(const QString &group, const QString &name, const QPoint &value);
template <class T>
T readEntry(const QString &group, const QString &name, const T &def = QVariant::Invalid );
QString readEntry(const QString &group, const QString &name, const QString &def = QString());
int readNumEntry(const QString &group, const QString &name, int def = 0);
unsigned int readUnsignedNumEntry(const QString &group, const QString &name, unsigned int def = 0);
double readDoubleNumEntry(const QString &group, const QString &name, double def = 0.0);
bool readBoolEntry(const QString &group, const QString &name, bool def = false);
QRect readRectEntry(const QString &group, const QString &name, const QRect *def = 0L);
QSize readSizeEntry(const QString &group, const QString &name, const QSize *def = 0L);
QColor readColorEntry(const QString &group, const QString &name, const QColor *def = 0L);
QFont readFontEntry(const QString &group, const QString &name, const QFont *def = 0L);
QPoint readPointEntry(const QString &group, const QString &name, const QPoint *def = 0L);
void removeVariable(const QString &group, const QString &name);
void addVariable(const QString &group, const QString &name, const QString &value);
void addVariable(const QString &group, const QString &name, const char *value);
void addVariable(const QString &group, const QString &name, const int value);
void addVariable(const QString &group, const QString &name, const double value);
void addVariable(const QString &group, const QString &name, const bool value);
void addVariable(const QString &group, const QString &name, const QRect &value);
void addVariable(const QString &group, const QString &name, const QSize &value);
void addVariable(const QString &group, const QString &name, const QColor &value);
void addVariable(const QString &group, const QString &name, const QFont &value);
void addVariable(const QString &group, const QString &name, const QPoint &value);
};
......
Markdown is supported
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