Bookmarks: Handle enter and delete keys

Change-Id: I169dcc02f02a647b0a2ae6478227a852be922de2
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Orgad Shaneh
2013-07-23 16:51:28 +03:00
committed by Orgad Shaneh
parent fdaddec7d1
commit 905aeeadcc
2 changed files with 13 additions and 0 deletions

View File

@@ -219,6 +219,8 @@ BookmarkView::BookmarkView(QWidget *parent) :
connect(this, SIGNAL(clicked(QModelIndex)),
this, SLOT(gotoBookmark(QModelIndex)));
connect(this, SIGNAL(activated(QModelIndex)),
this, SLOT(gotoBookmark(QModelIndex)));
ICore::addContextObject(m_bookmarkContext);
@@ -280,6 +282,16 @@ void BookmarkView::removeBookmark(const QModelIndex& index)
m_manager->removeBookmark(bm);
}
void BookmarkView::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Delete) {
removeBookmark(currentIndex());
event->accept();
return;
}
QListView::keyPressEvent(event);
}
void BookmarkView::removeAll()
{
const QString key = QLatin1String("Bookmarks.DontAskAgain");

View File

@@ -161,6 +161,7 @@ protected slots:
protected:
void contextMenuEvent(QContextMenuEvent *event);
void removeBookmark(const QModelIndex &index);
void keyPressEvent(QKeyEvent *event);
private:
BookmarkContext *m_bookmarkContext;
QModelIndex m_contextMenuIndex;