2021-09-30 09:43:29 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
2024-05-20 12:18:44 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2021-09-30 09:43:29 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
2021-10-14 14:29:33 +00:00
|
|
|
property var bookmarksModel: bookmarkModule.model
|
2021-09-30 09:43:29 +00:00
|
|
|
|
|
|
|
function addBookmark(url, name)
|
|
|
|
{
|
2021-10-14 14:29:33 +00:00
|
|
|
bookmarkModule.addBookmark(url, name)
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
|
2021-10-14 14:29:33 +00:00
|
|
|
function deleteBookmark(url)
|
2021-09-30 09:43:29 +00:00
|
|
|
{
|
2021-10-14 14:29:33 +00:00
|
|
|
bookmarkModule.deleteBookmark(url)
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
|
2021-10-14 14:29:33 +00:00
|
|
|
function updateBookmark(originalUrl, newUrl, newName)
|
2021-09-30 09:43:29 +00:00
|
|
|
{
|
2021-10-14 14:29:33 +00:00
|
|
|
bookmarkModule.updateBookmark(originalUrl, newUrl, newName)
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getBookmarkIndexByUrl(url)
|
|
|
|
{
|
2021-10-14 14:29:33 +00:00
|
|
|
return bookmarkModule.model.getBookmarkIndexByUrl(url)
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getCurrentFavorite(url) {
|
|
|
|
if (!url) {
|
|
|
|
return null
|
|
|
|
}
|
2021-10-14 14:29:33 +00:00
|
|
|
const index = bookmarkModule.model.getBookmarkIndexByUrl(url)
|
2021-09-30 09:43:29 +00:00
|
|
|
if (index === -1) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2024-05-20 12:18:44 +00:00
|
|
|
const item = SQUtils.ModelUtils.get(bookmarkModule.model, index)
|
|
|
|
|
2021-09-30 09:43:29 +00:00
|
|
|
return {
|
|
|
|
url: url,
|
2024-05-20 12:18:44 +00:00
|
|
|
name: item.name,
|
|
|
|
image: item.imageUrl
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|