#include "trace.h"
BookmarksDialog::BookmarksDialog(Book *book_, QWidget *parent):
- ListWindow(tr("(No bookmarks)"), parent), book(book_)
+ ListWindow(tr("(No bookmarks)\n"), parent), book(book_)
{
setWindowTitle(tr("Bookmarks"));
if (!book) {
addButton(tr("Add bookmark"), this, SLOT(onAdd()), "add");
- // FIXME
- // connect(list, SIGNAL(activated(const QModelIndex &)),
- // this, SLOT(onItemActivated(const QModelIndex &)));
+ connect(this, SIGNAL(activated(const QModelIndex &)),
+ this, SLOT(onItemActivated(const QModelIndex &)));
}
void BookmarksDialog::onGo()
{
TRACE;
- // FIXME
- // QModelIndex current = list->currentIndex();
- // if (current.isValid()) {
- // emit goToBookmark(current.row());
- // close();
- // }
+ QModelIndex current = currentItem();
+ if (current.isValid()) {
+ emit goToBookmark(current.row());
+ close();
+ }
}
void BookmarksDialog::onItemActivated(const QModelIndex &index)
void BookmarksDialog::onDelete(bool really)
{
-#if 0
- // FIXME
- QModelIndex current = list->currentIndex();
+ QModelIndex current = currentItem();
if (!current.isValid()) {
return;
}
}
}
int row = current.row();
- list->model()->removeRow(row);
+ model()->removeRow(row);
book->deleteBookmark(row);
-#endif
}
list->setCurrentItem(list->item(index + buttons.count()));
}
+QModelIndex ListWindow::currentItem() const
+{
+ TRACE;
+ QListWidgetItem *currentItem = list->currentItem();
+ if (currentItem) {
+ int row = list->row(currentItem) - buttons.count();
+ qDebug() << "Current row is" << row;
+ return mModel->index(row, 0);
+ }
+ return QModelIndex();
+}
+
#ifdef Q_WS_MAEMO_5
void ListWindow::closeEvent(QCloseEvent *event)
QAction *addMenuAction(const QString &title, QObject *receiver,
const char *slot);
+ /** Get current (selected) item. */
+ QModelIndex currentItem() const;
+
signals:
/** Emitted when a list item is activated. */
void activated(const QModelIndex &index);