Commit 3cb662cd authored by Adam Reichold's avatar Adam Reichold Committed by Albert Astals Cid

Add a method the check if an outline item has children to avoid having to...

Add a method the check if an outline item has children to avoid having to eagerly expand the hierarchy anyway.
parent 3376db5e
......@@ -147,6 +147,17 @@ QString OutlineItem::uri() const
return uri;
}
bool OutlineItem::hasChildren() const
{
bool result = false;
if (::OutlineItem *data = m_data->data) {
result = data->hasKids();
}
return result;
}
QVector<OutlineItem> OutlineItem::children() const
{
QVector<OutlineItem> result;
......
......@@ -1038,6 +1038,13 @@ delete it;
**/
QString uri() const;
/**
Determines if this item has any child items
\returns true if there are any child items
**/
bool hasChildren() const;
/**
Gets the child items of this item
......
......@@ -32,6 +32,7 @@ void TestOutline::checkOutline_xr02()
QCOMPARE(fooDest->pageNumber(), 1);
QVERIFY(foo.externalFileName().isEmpty());
QVERIFY(foo.uri().isEmpty());
QVERIFY(!foo.hasChildren());
QVERIFY(foo.children().isEmpty());
const auto &bar = outline[1];
......@@ -43,6 +44,7 @@ void TestOutline::checkOutline_xr02()
QCOMPARE(barDest->pageNumber(), 2);
QVERIFY(bar.externalFileName().isEmpty());
QVERIFY(bar.uri().isEmpty());
QVERIFY(!bar.hasChildren());
QVERIFY(bar.children().isEmpty());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment