always show expand icon on folders
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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_;
|
||||
|
||||
Reference in New Issue
Block a user