1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +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,11 +269,16 @@ 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();
if (row < 0) {
row = parent->children().count() - 1;
}
else {
const int initialIndex = bookmark->parent()->children().indexOf(bookmark); const int initialIndex = bookmark->parent()->children().indexOf(bookmark);
BookmarksToolbarButton* current = buttonAt(m_dropPos); if ((row > 0) && (initialIndex < row)) {
if (initialIndex < m_layout->indexOf(current)) {
row -= 1; row -= 1;
} }
}
} else { } else {
const QUrl url = mime->urls().at(0); const QUrl url = mime->urls().at(0);
const QString title = mime->hasText() ? mime->text() : QString::fromUtf8(url.toEncoded(QUrl::RemoveScheme)); const QString title = mime->hasText() ? mime->text() : QString::fromUtf8(url.toEncoded(QUrl::RemoveScheme));