Actually delete books from database. Delete all books when "Clear
authorAkos Polster <akos@pipacs.com>
Fri, 29 Oct 2010 23:29:32 +0000 (01:29 +0200)
committerAkos Polster <akos@pipacs.com>
Fri, 29 Oct 2010 23:29:32 +0000 (01:29 +0200)
settings" selected.

devtools.cpp
model/bookdb.cpp
model/bookdb.h
pkg/changelog

index 49a32ad..c3938c7 100644 (file)
@@ -5,6 +5,7 @@
 #include "trace.h"
 #include "settings.h"
 #include "toolbuttonbox.h"
+#include "bookdb.h"
 
 DevTools::DevTools(QWidget *parent): Dyalog(parent, false)
 {
@@ -36,6 +37,7 @@ void DevTools::onClear()
                                  "application will be restarted. Continue?"),
                               QMessageBox::Yes | QMessageBox::No)) {
         QSettings().clear();
+        BookDb::instance()->removeAll();
         QApplication::exit(1000);
     }
 }
index a8e16f5..2e13c80 100644 (file)
@@ -102,8 +102,13 @@ void BookDb::save(const QString &book, const QVariantHash &data)
 
 void BookDb::remove(const QString &book)
 {
-    // FIXME
-    Q_UNUSED(book);
+    Trace t("BookDb::remove");
+    qDebug() << book;
+    QSqlQuery query("delete from book where name = ?");
+    query.bindValue(0, book);
+    if (!query.exec()) {
+        qCritical() << "Query failed:" << query.lastError().text();
+    }
 }
 
 QStringList BookDb::books()
@@ -122,3 +127,10 @@ QStringList BookDb::books()
     qDebug() << ret;
     return ret;
 }
+
+void BookDb::removeAll()
+{
+    foreach (QString book, books()) {
+        remove(book);
+    }
+}
index 9b287a8..418cc15 100644 (file)
@@ -15,6 +15,7 @@ public:
     QVariantHash load(const QString &book);
     void save(const QString &book, const QVariantHash &data);
     void remove(const QString &book);
+    void removeAll();
     QStringList books();
 
 private:
index 03afeeb..e474909 100644 (file)
@@ -2,9 +2,9 @@ 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
   * Bookmarks to have notes
+  * Actually delete books from database
 
  -- Akos Polster <akos@pipacs.com>  Sat, 10 Oct 2010 02:00:00 +0200