From eb7454931af4ddb10783fd9f3d93eb1251aeb5fb Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Sun, 5 Dec 2010 20:07:34 +0100 Subject: [PATCH] Improve bookmark management on Symbian. --- bookmarksdialog.cpp | 41 +++++++++++++++++++++++++++++++---------- bookmarksdialog.h | 6 +++++- widgets/listwindow.cpp | 6 +----- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/bookmarksdialog.cpp b/bookmarksdialog.cpp index 3f4bb8c..9f81259 100644 --- a/bookmarksdialog.cpp +++ b/bookmarksdialog.cpp @@ -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 +} diff --git a/bookmarksdialog.h b/bookmarksdialog.h index 018822d..d0812b4 100644 --- a/bookmarksdialog.h +++ b/bookmarksdialog.h @@ -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; }; diff --git a/widgets/listwindow.cpp b/widgets/listwindow.cpp index 291da6b..e44a781 100644 --- a/widgets/listwindow.cpp +++ b/widgets/listwindow.cpp @@ -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 } -- 1.7.9.5