always show expand icon on folders

This commit is contained in:
itsmattkc
2019-06-21 12:00:08 -07:00
parent 459ad13eda
commit 8d66f11d6d
2 changed files with 25 additions and 0 deletions
+18
View File
@@ -141,3 +141,21 @@ QVariant ProjectViewModel::headerData(int section, Qt::Orientation orientation,
return QAbstractItemModel::headerData(section, orientation, role);
}
bool ProjectViewModel::hasChildren(const QModelIndex &parent) const
{
// Check if this is a valid index
if (parent.isValid()) {
Item* item = static_cast<Item*>(parent.internalPointer());
// Check if this item is a kFolder type
// If it's a folder, we always return TRUE in order to always show the "expand triangle" icon,
// even when there are no "physical" children
if (item->type() == Item::kFolder) {
return true;
}
}
// Otherwise, return default behavior
return QAbstractItemModel::hasChildren(parent);
}