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

LocationCompleter: Only allow to delete bookmarks and history items

This commit is contained in:
David Rosca 2018-01-03 20:52:27 +01:00
parent 89aa7259f9
commit 139a8dc8f1
3 changed files with 9 additions and 8 deletions

View File

@ -284,10 +284,11 @@ void LocationCompleter::indexDeleteRequested(const QModelIndex &index)
if (index.data(LocationCompleterModel::BookmarkRole).toBool()) {
BookmarkItem* bookmark = static_cast<BookmarkItem*>(index.data(LocationCompleterModel::BookmarkItemRole).value<void*>());
mApp->bookmarks()->removeBookmark(bookmark);
}
else {
} else if (index.data(LocationCompleterModel::HistoryRole).toBool()) {
int id = index.data(LocationCompleterModel::IdRole).toInt();
mApp->history()->deleteHistoryEntry(id);
} else {
return;
}
s_view->setUpdatesEnabled(false);

View File

@ -1,6 +1,6 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,6 +33,7 @@ public:
TitleRole,
UrlRole,
CountRole,
HistoryRole,
BookmarkRole,
BookmarkItemRole,
SearchStringRole,

View File

@ -1,6 +1,6 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2014-2017 David Rosca <nowrep@gmail.com>
* Copyright (C) 2014-2018 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -134,7 +134,7 @@ void LocationCompleterRefreshJob::runJob()
item->setText(m_searchString);
item->setData(m_searchString, LocationCompleterModel::UrlRole);
item->setData(m_searchString, LocationCompleterModel::SearchStringRole);
item->setData(QVariant(true), LocationCompleterModel::VisitSearchItemRole);
item->setData(true, LocationCompleterModel::VisitSearchItemRole);
if (!m_domainCompletion.isEmpty()) {
const QUrl url = QUrl(QSL("http://%1").arg(m_domainCompletion));
item->setData(IconProvider::imageForDomain(url), LocationCompleterModel::ImageRole);
@ -162,7 +162,7 @@ void LocationCompleterRefreshJob::completeFromHistory()
item->setData(bookmark->title(), LocationCompleterModel::TitleRole);
item->setData(bookmark->url(), LocationCompleterModel::UrlRole);
item->setData(bookmark->visitCount(), LocationCompleterModel::CountRole);
item->setData(QVariant(true), LocationCompleterModel::BookmarkRole);
item->setData(true, LocationCompleterModel::BookmarkRole);
item->setData(QVariant::fromValue<void*>(static_cast<void*>(bookmark)), LocationCompleterModel::BookmarkItemRole);
item->setData(m_searchString, LocationCompleterModel::SearchStringRole);
@ -193,7 +193,7 @@ void LocationCompleterRefreshJob::completeFromHistory()
item->setData(query.value(2), LocationCompleterModel::TitleRole);
item->setData(url, LocationCompleterModel::UrlRole);
item->setData(query.value(3), LocationCompleterModel::CountRole);
item->setData(QVariant(false), LocationCompleterModel::BookmarkRole);
item->setData(true, LocationCompleterModel::HistoryRole);
item->setData(m_searchString, LocationCompleterModel::SearchStringRole);
m_items.append(item);
@ -214,7 +214,6 @@ void LocationCompleterRefreshJob::completeMostVisited()
item->setData(query.value(0), LocationCompleterModel::IdRole);
item->setData(query.value(2), LocationCompleterModel::TitleRole);
item->setData(url, LocationCompleterModel::UrlRole);
item->setData(QVariant(false), LocationCompleterModel::BookmarkRole);
m_items.append(item);
}