Improve bookmark management on Symbian.
authorAkos Polster <akos@pipacs.com>
Sun, 5 Dec 2010 19:07:34 +0000 (20:07 +0100)
committerAkos Polster <akos@pipacs.com>
Sun, 5 Dec 2010 19:07:34 +0000 (20:07 +0100)
bookmarksdialog.cpp
bookmarksdialog.h
widgets/listwindow.cpp

index 3f4bb8c..9f81259 100644 (file)
@@ -34,7 +34,9 @@ BookmarksDialog::BookmarksDialog(Book *book_, QWidget *parent):
     setModel(model);
 
     addButton(tr("Add bookmark"), this, SLOT(onAdd()), "add");
-    addItemButton(tr("Delete bookmark"), this, SLOT(onDelete()), "remove");
+    addItemButton(tr("Go to bookmark"), this, SLOT(onGo()), "goto");
+    addItemButton(tr("Edit bookmark"), this, SLOT(onEdit()), "edit");
+    addItemButton(tr("Delete bookmark"), this, SLOT(onDelete()), "delete");
 
     connect(this, SIGNAL(activated(const QModelIndex &)),
             this, SLOT(onItemActivated(const QModelIndex &)));
@@ -52,20 +54,26 @@ void BookmarksDialog::onGo()
 
 void BookmarksDialog::onItemActivated(const QModelIndex &index)
 {
+    TRACE;
+#ifdef Q_WS_MAEMO_5
     switch ((new BookmarkInfoDialog(book, index.row(), this))->exec()) {
     case BookmarkInfoDialog::GoTo:
         onGo();
         break;
     case BookmarkInfoDialog::Delete:
-        onDelete(true);
+        reallyDelete();
         break;
     default:
         ;
     }
+#else
+    Q_UNUSED(index);
+#endif
 }
 
 void BookmarksDialog::onAdd()
 {
+    TRACE;
     bool ok;
     QString text = QInputDialog::getText(this, tr("Add bookmark"),
         tr("Note (optional):"), QLineEdit::Normal, QString(), &ok);
@@ -75,20 +83,33 @@ void BookmarksDialog::onAdd()
     }
 }
 
-void BookmarksDialog::onDelete(bool really)
+void BookmarksDialog::onDelete()
+{
+    TRACE;
+    if (!currentItem().isValid()) {
+        return;
+    }
+    if (QMessageBox::Yes !=
+        QMessageBox::question(this, tr("Delete bookmark"),
+            tr("Delete bookmark?"), QMessageBox::Yes | QMessageBox::No)) {
+        return;
+    }
+    reallyDelete();
+}
+
+void BookmarksDialog::reallyDelete()
 {
+    TRACE;
     QModelIndex current = currentItem();
     if (!current.isValid()) {
         return;
     }
-    if (!really) {
-        if (QMessageBox::Yes !=
-            QMessageBox::question(this, tr("Delete bookmark"),
-                tr("Delete bookmark?"), QMessageBox::Yes | QMessageBox::No)) {
-            return;
-        }
-    }
     int row = current.row();
     model()->removeRow(row);
     book->deleteBookmark(row);
 }
+
+void BookmarksDialog::onEdit()
+{
+    // FIXME: Implement me
+}
index 018822d..d0812b4 100644 (file)
@@ -23,10 +23,14 @@ signals:
 public slots:
     void onGo();
     void onAdd();
-    void onDelete(bool really = false);
+    void onDelete();
+    void onEdit();
     void onItemActivated(const QModelIndex &index);
 
 protected:
+    void reallyDelete();
+
+private:
     Book *book;
     QStringList data;
 };
index 291da6b..e44a781 100644 (file)
@@ -114,7 +114,6 @@ void ListWindow::addButton(const QString &title, QObject *receiver,
     buttons.append(b);
 #else
     (void)addToolBarAction(receiver, slot, iconName, title, true);
-    (void)addMenuAction(title, receiver, slot);
 #endif
 }
 
@@ -130,11 +129,8 @@ void ListWindow::addItemButton(const QString &title, QObject *receiver,
 #else
     QAction *toolBarAction =
             addToolBarAction(receiver, slot, iconName, title, true);
-    // QAction *menuAction = addMenuAction(title, receiver, slot);
-    // toolBarAction->setEnabled(false);
-    // menuAction->setEnabled(false);
+    toolBarAction->setEnabled(false);
     itemActions.append(toolBarAction);
-    // itemActions.append(menuAction);
 #endif
 }