6#include <QtCore/QCoreApplication>
7#include <QtCore/QDebug>
11using namespace Qt::StringLiterals;
21 qDeleteAll(m_children);
40 m_children.append(child);
46 if (number >= 0 && number < m_children.size())
47 return m_children[number];
53 return m_children.size();
59 return m_parent->m_children.indexOf(
const_cast<
BookmarkItem*>(
this));
69 if (column == 1 || column == UserRoleUrl)
72 if (column == UserRoleFolder)
73 return m_data[1].toString() ==
"Folder"_L1;
75 if (column == UserRoleExpanded)
91 if (column == 0 || column == 1)
94 if (column == UserRoleUrl || column == UserRoleFolder)
97 if (column == UserRoleExpanded)
103 m_data[index] = newValue;
110 if (position < 0 || position > m_children.size())
113 for (
int row = 0; row < count; ++row) {
114 m_children.insert(position,
new BookmarkItem(DataVector()
116 ? QCoreApplication::translate(
"BookmarkItem",
"New Folder")
117 : QCoreApplication::translate(
"BookmarkItem",
"Untitled"))
118 << (isFolder ?
"Folder" :
"about:blank") <<
false,
this));
127 if (position < 0 || position > m_children.size())
130 for (
int row = 0; row < count; ++row)
131 delete m_children.takeAt(position);
139 const QString tree(indent,
' ');
140 qDebug() << tree + (data(UserRoleFolder).toBool() ?
"Folder" :
"Bookmark")
141 <<
"Label:" << data(0).toString() <<
"parent:" << m_parent <<
"this:"
144 for (BookmarkItem *item : m_children)
145 item->dumpTree(indent + 4);
QList< QVariant > DataVector
QVariant data(int column) const
BookmarkItem * child(int number) const
bool insertChildren(bool isFolder, int position, int count)
void addChild(BookmarkItem *child)
void setParent(BookmarkItem *parent)
bool setData(int column, const QVariant &value)
bool removeChildren(int position, int count)
BookmarkItem * parent() const
void setData(const DataVector &data)
BookmarkItem(const DataVector &data, BookmarkItem *parent=nullptr)
void dumpTree(int indent) const
Combined button and popup list for selecting options.