1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

BookmarksToolbar: Fix drag and drop

- Fix crash
- Fix bookmark final position

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2024-08-03 22:25:33 +02:00
parent 6e7047f7ec
commit 06ea9c6b9c
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B

View File

@ -269,10 +269,15 @@ void BookmarksToolbar::dropEvent(QDropEvent* e)
if (mime->hasFormat(BookmarksButtonMimeData::mimeType())) { if (mime->hasFormat(BookmarksButtonMimeData::mimeType())) {
const auto* bookmarkMime = static_cast<const BookmarksButtonMimeData*>(mime); const auto* bookmarkMime = static_cast<const BookmarksButtonMimeData*>(mime);
bookmark = bookmarkMime->item(); bookmark = bookmarkMime->item();
const int initialIndex = bookmark->parent()->children().indexOf(bookmark);
BookmarksToolbarButton* current = buttonAt(m_dropPos); if (row < 0) {
if (initialIndex < m_layout->indexOf(current)) { row = parent->children().count() - 1;
row -= 1; }
else {
const int initialIndex = bookmark->parent()->children().indexOf(bookmark);
if ((row > 0) && (initialIndex < row)) {
row -= 1;
}
} }
} else { } else {
const QUrl url = mime->urls().at(0); const QUrl url = mime->urls().at(0);