Skip to content

Commit

Permalink
fix: return data based on role name from TreeItem
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezah95 committed Dec 7, 2022
1 parent b09a9e6 commit f2f5cb9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions treemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ bool TreeModel::insert(TreeItem* item, const QModelIndex& parent, int pos)

QVariant TreeModel::data(const QModelIndex& index, int role) const
{
qDebug() << "data is called";

if (!index.isValid()) {
return QVariant();
}

if (role != Qt::DisplayRole) {
if (!mRoleNames.contains(role)) {
return QVariant();
}

TreeItem* item = static_cast<TreeItem*>(index.internalPointer());

return ""; // item->data(index.column());
QString roleName = mRoleNames.value(role);

return item->data().value(roleName);
}

Qt::ItemFlags TreeModel::flags(const QModelIndex& index) const
Expand Down

0 comments on commit f2f5cb9

Please sign in to comment.