Symbian fixes.
authorAkos Polster <akos@pipacs.com>
Mon, 18 Oct 2010 22:33:24 +0000 (00:33 +0200)
committerAkos Polster <akos@pipacs.com>
Mon, 18 Oct 2010 22:33:24 +0000 (00:33 +0200)
model/bookdb.cpp
pkg/changelog
widgets/listview.h
widgets/listwindow.cpp
widgets/listwindow.h

index c2987c0..a8e16f5 100644 (file)
@@ -29,13 +29,16 @@ BookDb::BookDb()
     QFileInfo info(Platform::dbPath());
     if (!info.exists()) {
         QDir dbDir;
-        dbDir.mkpath(info.absolutePath());
+        if (!dbDir.mkpath(info.absolutePath())) {
+            qCritical() << "Could not create" << info.absolutePath();
+        }
         shouldCreate = true;
     }
     db = QSqlDatabase::addDatabase("QSQLITE");
-    db.setDatabaseName(Platform::dbPath());
+    db.setDatabaseName(QDir::toNativeSeparators(Platform::dbPath()));
     if (!db.open()) {
-        qCritical() << "Could not open" << Platform::dbPath();
+        qCritical() << "Could not open" << Platform::dbPath() << ": Error"
+                << db.lastError().text();
     }
     if (shouldCreate) {
         create();
@@ -51,8 +54,10 @@ void BookDb::create()
 {
     Trace t("BookDb::create");
     QSqlQuery query;
-    if (!query.exec("create table book (name text primary key, content blob)")) {
-        qCritical() << "Failed to create database";
+    if (!query.exec("create table book "
+                    "(name text primary key, content blob)")) {
+        qCritical() << "Failed to create database:"
+                << query.lastError().text();
     }
 }
 
@@ -66,7 +71,7 @@ QVariantHash BookDb::load(const QString &book)
     query.bindValue(0, book);
     query.setForwardOnly(true);
     if (!query.exec()) {
-        qCritical() << "Query failed";
+        qCritical() << "Query failed:" << query.lastError().text();
         return ret;
     }
     while (query.next()) {
@@ -91,7 +96,7 @@ void BookDb::save(const QString &book, const QVariantHash &data)
     query.bindValue(0, book);
     query.bindValue(1, bytes);
     if (!query.exec()) {
-        qCritical() << "Query failed";
+        qCritical() << "Query failed:" << query.lastError().text();
     }
 }
 
@@ -108,7 +113,7 @@ QStringList BookDb::books()
     QSqlQuery query("select name from book");
     query.setForwardOnly(true);
     if (!query.exec()) {
-        qCritical() << "Query failed";
+        qCritical() << "Query failed:" << query.lastError().text();
         return ret;
     }
     while (query.next()) {
index d535473..58df6ef 100644 (file)
@@ -2,6 +2,8 @@ dorian (0.3.1-1) unstable; urgency=low
 
   * Fix sorting of library
   * Fix book view kinetic scrolling on Symbian
+  * Failed attempt to add kinetic scrolling to lists on Symbian
+  * Fix database creation on Symbian
 
  -- Akos Polster <akos@pipacs.com>  Sat, 10 Oct 2010 02:00:00 +0200
 
index d373320..be23563 100644 (file)
@@ -10,7 +10,9 @@ class ListView: public QListView
 
 public:
     explicit ListView(QWidget *parent = 0): QListView(parent) {
+#ifndef Q_OS_SYMBIAN
         setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+#endif
         setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
         setUniformItemSizes(true);
         setEditTriggers(QAbstractItemView::NoEditTriggers);
index 48ef599..a7bf50b 100644 (file)
@@ -5,9 +5,13 @@
 #include "listview.h"
 #include "platform.h"
 
+#ifdef Q_OS_SYMBIAN
+#include "flickcharm.h"
+#endif
+
 ListWindow::ListWindow(QWidget *parent): QMainWindow(parent), list(0)
 {
-#ifdef Q_WS_MAEMO_5
+#if defined(Q_WS_MAEMO_5)
     setAttribute(Qt::WA_Maemo5StackedWindow, true);
     popup = new QMenu(this);
 
@@ -32,16 +36,17 @@ ListWindow::ListWindow(QWidget *parent): QMainWindow(parent), list(0)
     setCentralWidget(frame);
     contentLayout = new QHBoxLayout();
     frame->setLayout(contentLayout);
-#   ifdef Q_OS_SYMBIAN
+    buttonBox = new QDialogButtonBox(Qt::Vertical, this);
+    contentLayout->addWidget(buttonBox);
+#endif // Q_WS_MAEMO_5
+
+#ifdef Q_OS_SYMBIAN
+    charm = 0;
     QAction *closeAction = new QAction(parent? tr("Back"): tr("Exit"), this);
     closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
     connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
     QMainWindow::addAction(closeAction);
-#   else
-    buttonBox = new QDialogButtonBox(Qt::Vertical, this);
-    contentLayout->addWidget(buttonBox);
-#   endif // Q_OS_SYMBIAN
-#endif // Q_WS_MAEMO_5
+#endif // Q_OS_SYMBIAN
 
 #ifdef Q_WS_MAC
     addAction(tr("Close"), this, SLOT(close()), QString(),
@@ -53,7 +58,7 @@ void ListWindow::addList(ListView *listView)
 {
     Trace t("ListWindow::addList");
     list = listView;
-#ifdef Q_WS_MAEMO_5
+#if defined(Q_WS_MAEMO_5)
     list->installEventFilter(this);
     list->setMinimumHeight(list->contentsHeight());
     contentLayout->addWidget(list);
@@ -65,7 +70,15 @@ void ListWindow::addList(ListView *listView)
             this, SLOT(onModelChanged()));
 #else
     contentLayout->insertWidget(0, list);
-#endif
+#endif // Q_WS_MAEMO5
+
+#ifdef Q_OS_SYMBIAN
+    if (!charm) {
+        charm = new FlickCharm(this);
+    }
+    charm->activateOn(list);
+#endif // Q_OS_SYMBIAN
+
     connect(list->selectionModel(),
       SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
       this,
index 956c447..c9c958e 100644 (file)
@@ -13,6 +13,7 @@ class QModelIndex;
 class QItemSelection;
 class QEvent;
 class ListView;
+class FlickCharm;
 
 /** A window with a list and menu actions (Maemo) or buttons (non-Maemo). */
 class ListWindow: public QMainWindow
@@ -66,6 +67,9 @@ protected:
     QDialogButtonBox *buttonBox;
     QList<QPushButton *> itemButtons;
 #endif // Q_WS_MAEMO_5
+#ifdef Q_OS_SYMBIAN
+    FlickCharm *charm;
+#endif
     QBoxLayout *contentLayout;
     ListView *list;
 };