--- a/homescreenapp/hsdomainmodel/src/hsdatabase.cpp Wed Aug 18 09:40:07 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hsdatabase.cpp Thu Sep 02 20:17:27 2010 +0300
@@ -31,7 +31,7 @@
QVariantList toVariantList(const QList<T> &list)
{
QVariantList vlist;
- for (int i=0; i<list.count(); ++i) {
+ for (int i = 0; i < list.count(); ++i) {
T item = list.at(i);
vlist << item;
}
@@ -813,6 +813,36 @@
return false;
}
+bool HsDatabase::updateWidgetZValues(const QHash<int, qreal> &data, Qt::Orientation orientation)
+{
+ if (!checkConnection()) {
+ return false;
+ }
+
+ QString key = orientation == Qt::Vertical ?
+ QLatin1String("portrait") : QLatin1String("landscape");
+
+ QSqlQuery query(QSqlDatabase::database(mConnectionName));
+
+ QString statement =
+ "UPDATE WidgetPresentations "
+ "SET zValue = ? "
+ "WHERE key = ? AND widgetId = ?";
+
+ if (query.prepare(statement)) {
+ query.addBindValue(toVariantList(data.values()));
+ query.addBindValue(toVariantList(key, data.count()));
+ query.addBindValue(toVariantList(data.keys()));
+ if (!query.execBatch()) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ return true;
+}
+
/*!
Sets the database instance. The existing instance
will be deleted.