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);
}
+7
View File
@@ -24,6 +24,12 @@ public:
kRate
};
/**
* @brief ProjectViewModel Constructor
*
* @param parent
* Parent object for memory handling
*/
ProjectViewModel(QObject* parent);
/**
@@ -55,6 +61,7 @@ public:
/** Optional Qt QAbstractItemModel overrides */
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
private:
Project* project_;