From 77e928569a379f7eeecabacb07c819a1f21f7bd5 Mon Sep 17 00:00:00 2001 From: Giacomo Barazzetti Date: Wed, 12 Dec 2018 22:21:19 +0100 Subject: [PATCH] Create new bookmark items near the current one (over it) Summary: Currently in the bookmarks manager the user can create new items via the contextual menu, so a position is implicitly chosen, but the new items are always inserted at the first position in the list. This change aims to add new items just before the current (selected) one. If the selected item is a folder the behavior is unchanged (the new item will be inserted at the first position in that folder). Test Plan: - Select a separator/url item - Add a new item (separator/url/folder) - The new item is inserted just before the previously selected one Reviewers: #falkon, drosca Reviewed By: #falkon, drosca Subscribers: cullmann, falkon Tags: #falkon Differential Revision: https://phabricator.kde.org/D14930 --- src/lib/bookmarks/bookmarksmanager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/bookmarks/bookmarksmanager.cpp b/src/lib/bookmarks/bookmarksmanager.cpp index cf6bb1656..bacbfcb29 100644 --- a/src/lib/bookmarks/bookmarksmanager.cpp +++ b/src/lib/bookmarks/bookmarksmanager.cpp @@ -292,7 +292,11 @@ void BookmarksManager::addBookmark(BookmarkItem* item) BookmarkItem* parent = parentForNewBookmark(); Q_ASSERT(parent); - m_bookmarks->insertBookmark(parent, 0, item); + int row = 0; + if (m_selectedBookmark->isUrl() || m_selectedBookmark->isSeparator()) { + row = m_bookmarks->model()->index(m_selectedBookmark).row(); + } + m_bookmarks->insertBookmark(parent, row, item); // Select newly added bookmark ui->tree->selectBookmark(item);