Commit 69963d8c authored by Bernhard Beschow's avatar Bernhard Beschow

no need to override QAbstractItemModel::hasChildren()

The default implementation does exactly what is needed and has no disadvantages regarding performance. Not having to maintain this method and keeping its logic in synch with rowCount() provides an advantage, however.
parent d74d365d
......@@ -117,50 +117,6 @@ GeoDataTreeModel::~GeoDataTreeModel()
delete d;
}
bool GeoDataTreeModel::hasChildren( const QModelIndex &parent ) const
{
const GeoDataObject *parentItem;
if ( parent.column() > 0 ) {
return false;
}
if ( !parent.isValid() ) {
parentItem = d->m_rootDocument;
} else {
parentItem = static_cast<const GeoDataObject *>(parent.internalPointer());
}
if ( !parentItem ) {
return false;
}
if (const auto placemark = geodata_cast<GeoDataPlacemark>(parentItem)) {
return dynamic_cast<const GeoDataMultiGeometry*>( placemark->geometry() );
}
if (const auto folder = geodata_cast<GeoDataFolder>(parentItem)) {
return folder->size();
}
if (const auto document = geodata_cast<GeoDataDocument>(parentItem)) {
return document->size();
}
if (const auto geometry = geodata_cast<GeoDataMultiGeometry>(parentItem)) {
return geometry->size();
}
if (const auto tour = geodata_cast<GeoDataTour>(parentItem)) {
return tour->playlist();
}
if (const auto playlist = geodata_cast<GeoDataPlaylist>(parentItem)) {
return playlist->size();
}
return false;
}
int GeoDataTreeModel::rowCount( const QModelIndex &parent ) const
{
// mDebug() << "rowCount";
......
......@@ -48,8 +48,6 @@ class MARBLE_EXPORT GeoDataTreeModel : public QAbstractItemModel
*/
~GeoDataTreeModel() override;
bool hasChildren(const QModelIndex &parent) const override;
/**
* Return the number of Items in the Model.
*/
......
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