Lukáš Tinkl a6c897929a chore: Remove custom rowData method from NIM's models
- Some NIM's models define additional (not part of the
QAbstractModelItem API) method rowData to allow access to model's data
on UI side
- The same job can be done relying fully on public QAbstractModelItem
API using ModelUtils utility. It gives full transparency if we need
nim's model or other like ListModel replacement in tests/storybook
- propagate `tokensStore` to unbreak the Browser's wallet menu

Fixes #14805
2024-05-20 18:02:20 +02:00

50 lines
1019 B
QML

pragma Singleton
import QtQuick 2.15
import StatusQ.Core.Utils 0.1 as SQUtils
QtObject {
id: root
property var bookmarksModel: bookmarkModule.model
function addBookmark(url, name)
{
bookmarkModule.addBookmark(url, name)
}
function deleteBookmark(url)
{
bookmarkModule.deleteBookmark(url)
}
function updateBookmark(originalUrl, newUrl, newName)
{
bookmarkModule.updateBookmark(originalUrl, newUrl, newName)
}
function getBookmarkIndexByUrl(url)
{
return bookmarkModule.model.getBookmarkIndexByUrl(url)
}
function getCurrentFavorite(url) {
if (!url) {
return null
}
const index = bookmarkModule.model.getBookmarkIndexByUrl(url)
if (index === -1) {
return null
}
const item = SQUtils.ModelUtils.get(bookmarkModule.model, index)
return {
url: url,
name: item.name,
image: item.imageUrl
}
}
}