This commit is contained in:
itsmattkc
2019-03-05 20:35:58 -08:00
parent 95977143d0
commit d287963c10
5 changed files with 62 additions and 46 deletions
+25 -2
View File
@@ -115,7 +115,30 @@ QModelIndex ProjectModel::parent(const QModelIndex &index) const {
if (parentItem == root_item)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
return createIndex(parentItem->row(), 0, parentItem);
}
bool ProjectModel::canFetchMore(const QModelIndex &parent) const
{
// Mostly implementing this because QSortFilterProxyModel will actually *ignore* a "true" result from hasChildren()
// and then query this value for a "true" result. So we need to override both this and hasChildren() to show a
// persistent childIndicator for folder items.
if (parent.isValid()
&& static_cast<Media*>(parent.internalPointer())->get_type() == MEDIA_TYPE_FOLDER) {
return true;
}
return QAbstractItemModel::canFetchMore(parent);
}
bool ProjectModel::hasChildren(const QModelIndex &parent) const
{
if (parent.isValid()
&& static_cast<Media*>(parent.internalPointer())->get_type() == MEDIA_TYPE_FOLDER) {
return true;
}
return QAbstractItemModel::hasChildren(parent);
}
bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int role) {
@@ -132,7 +155,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
}
int ProjectModel::rowCount(const QModelIndex &parent) const {
Media *parentItem;
Media *parentItem;
if (parent.column() > 0)
return 0;