forked from qt-creator/qt-creator
Utils: Fix treemodel's hasChildren
Basically this reverts 08e73d1a93
, but adds an
additional check for the column as the BaseTreeModel
implementation just allows children at the first column.
Main reason for this revert is that the variable choosers
used across Qt Creator did no more populate their
respective macro lists automatically.
Change-Id: I172506a9dbe18f20b152ec797f35feff717dc3cf
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -1028,6 +1028,14 @@ QVariant BaseTreeModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BaseTreeModel::hasChildren(const QModelIndex &idx) const
|
||||||
|
{
|
||||||
|
if (idx.column() > 0)
|
||||||
|
return false;
|
||||||
|
TreeItem *item = itemForIndex(idx);
|
||||||
|
return !item || item->hasChildren();
|
||||||
|
}
|
||||||
|
|
||||||
Qt::ItemFlags BaseTreeModel::flags(const QModelIndex &idx) const
|
Qt::ItemFlags BaseTreeModel::flags(const QModelIndex &idx) const
|
||||||
{
|
{
|
||||||
if (!idx.isValid())
|
if (!idx.isValid())
|
||||||
|
@@ -193,6 +193,7 @@ protected:
|
|||||||
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
|
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &idx) const override;
|
Qt::ItemFlags flags(const QModelIndex &idx) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
|
bool hasChildren(const QModelIndex &idx) const override;
|
||||||
|
|
||||||
bool canFetchMore(const QModelIndex &idx) const override;
|
bool canFetchMore(const QModelIndex &idx) const override;
|
||||||
void fetchMore(const QModelIndex &idx) override;
|
void fetchMore(const QModelIndex &idx) override;
|
||||||
|
Reference in New Issue
Block a user