Commit 039306e3 authored by Fabian Kosmale's avatar Fabian Kosmale
Browse files

avoid code duplication

parent caac1441
......@@ -187,12 +187,17 @@ void SQLiteConnection::query(const QString &q, const QVariantMap &bindings)
QVariantMap::const_iterator it = bindings.constBegin();
QVariantMap::const_iterator end = bindings.constEnd();
for ( ; it != end; it++) {
if (it.value().toList().first().type() == QVariant::Int) {
bind(it.key(), it.value().toList()[i].toInt());//Can we somehow compress the duplicated code?
} else if (it.value().toList().first().type() == QVariant::String) {
bind(it.key(), it.value().toList()[i].toString());
} else {
bind(it.key(), it.value().toList()[i].toByteArray());
const auto key = it.key ();
const auto elem = it.value().toList()[i];
switch (it.value().toList().first().type()) {
case QVariant::Int:
bind(key, elem.toInt());
break;
case QVariant::String:
bind(key, elem.toString());
break;
default:
bind(key, elem.toByteArray());
}
}
rowQuery(q);
......
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