Falkon Develop
Cross-platform Qt-based web browser
qmlbookmarktreenode.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "qmlbookmarktreenode.h"
19#include "mainapplication.h"
20#include "bookmarks.h"
21#include "qml/qmlstaticdata.h"
22#include <QQmlEngine>
23
25 : m_item(item)
26{
27 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
28}
29
31{
32 return m_item;
33}
34
36{
37 if (!m_item) {
38 return Invalid;
39 }
40
41 switch (m_item->type()) {
43 return Root;
44
46 return Url;
47
49 return Folder;
50
52 return Separator;
53
55 return Invalid;
56 }
57
58 return Invalid;
59}
60
62{
63 if (!m_item) {
64 return {};
65 }
66
67 return m_item->title();
68}
69
71{
72 if (!m_item) {
73 return {};
74 }
75
76 return m_item->urlString();
77}
78
80{
81 if (!m_item) {
82 return {};
83 }
84
85 return m_item->description();
86}
87
89{
90 if (!m_item) {
91 return {};
92 }
93
94 return m_item->keyword();
95}
96
98{
99 if (!m_item) {
100 return 0;
101 }
102
103 return m_item->visitCount();
104}
105
107{
108 if (!m_item) {
109 return nullptr;
110 }
111
113}
114
116{
117 return !mApp->bookmarks()->canBeModified(m_item);
118}
119
120QList<QObject*> QmlBookmarkTreeNode::children() const
121{
122 const QList<BookmarkItem*> items = m_item->children();
123 QList<QObject*> ret;
124 ret.reserve(items.size());
125 for (BookmarkItem *item : items) {
126 ret.append(QmlStaticData::instance().getBookmarkTreeNode(item));
127 }
128 return ret;
129}
QString keyword() const
QString urlString() const
QString description() const
int visitCount() const
BookmarkItem * parent() const
QList< BookmarkItem * > children() const
QString title() const
Type type() const
The class exposing the bookmark item to QML.
int visitCount
visit count of bookmark tree node.
QmlBookmarkTreeNode * parent
parent of bookmark tree node.
bool unmodifiable
checks if bookmark tree node is unmodifiable.
@ Invalid
Represents invalid bookmark item.
@ Folder
Represents the bookmark folder.
@ Separator
Represents the bookmark separator.
@ Url
Represents the single bookmark item of type url.
@ Root
Represents the root bookmark item.
QString description
description of bookmark tree node.
QList< QObject * > children
gets children of bookmark tree node.
QmlBookmarkTreeNode(BookmarkItem *item=nullptr)
QString title
title of bookmark tree node.
QString url
url of bookmark tree node.
QString keyword
keyword of bookmark tree node.
Type type
type of bookmark tree node.
static QmlStaticData & instance()
QmlBookmarkTreeNode * getBookmarkTreeNode(BookmarkItem *item)
#define mApp