Enable tracing to file. Attempt to fix last position restoration on S^3.
[dorian] / bookmarksdialog.cpp
index 08c4079..37ad543 100644 (file)
@@ -13,7 +13,7 @@ BookmarksDialog::BookmarksDialog(Book *book_, QWidget *parent):
         return;
     }
 
-    addAction(tr("Add bookmark"), this, SLOT(onAdd()), ":/icons/add.png");
+    addAction(tr("Add bookmark"), this, SLOT(onAdd()), "add");
 #ifndef Q_WS_MAEMO_5
     addItemAction(tr("Go to"), this, SLOT(onGo()));
     addItemAction(tr("Delete"), this, SLOT(onDelete()));
@@ -25,10 +25,14 @@ BookmarksDialog::BookmarksDialog(Book *book_, QWidget *parent):
         QString label("At ");
         label += QString::number((int)(100 * book_->
             getProgress(bookmark.part, bookmark.pos))) + "%";
+        if (!bookmark.note.isEmpty()) {
+            label += ": " + bookmark.note;
+        }
+        label += "\n";
         int chapterIndex = book_->chapterFromPart(bookmark.part);
         if (chapterIndex != -1) {
             QString chapterId = book_->chapters[chapterIndex];
-            label += "\nIn \"" + book_->content[chapterId].name + "\"";
+            label += "In \"" + book_->content[chapterId].name + "\"";
         }
         data.append(label);
     }
@@ -69,8 +73,13 @@ void BookmarksDialog::onItemActivated(const QModelIndex &index)
 
 void BookmarksDialog::onAdd()
 {
-    emit addBookmark();
-    close();
+    bool ok;
+    QString text = QInputDialog::getText(this, tr("Add bookmark"),
+        tr("Note (optional):"), QLineEdit::Normal, QString(), &ok);
+    if (ok) {
+        emit addBookmark(text);
+        close();
+    }
 }
 
 void BookmarksDialog::onDelete(bool really)
@@ -82,8 +91,7 @@ void BookmarksDialog::onDelete(bool really)
     if (!really) {
         if (QMessageBox::Yes !=
             QMessageBox::question(this, tr("Delete bookmark"),
-                                  tr("Delete bookmark?"),
-                                  QMessageBox::Yes | QMessageBox::No)) {
+                tr("Delete bookmark?"), QMessageBox::Yes | QMessageBox::No)) {
             return;
         }
     }