From a3b770c599ea414fadf28bffd1aef76a2367cc9d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 3 May 2009 01:29:19 -0400 Subject: Add data fetching for the text of the item --- sigmodr/tree/TreeModel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sigmodr/tree/TreeModel.cpp') diff --git a/sigmodr/tree/TreeModel.cpp b/sigmodr/tree/TreeModel.cpp index defaa218..15f8dae2 100644 --- a/sigmodr/tree/TreeModel.cpp +++ b/sigmodr/tree/TreeModel.cpp @@ -36,6 +36,15 @@ TreeModel::~TreeModel() QVariant TreeModel::data(const QModelIndex& index, const int role) const { + if (!index.isValid()) + return QVariant(); + TreeItem* item = static_cast(index.internalPointer()); + if (role == Qt::DisplayRole) + { + if (!index.column()) + return item->text(); + } + return QVariant(); } QModelIndex TreeModel::index(const int row, const int column, const QModelIndex& parent) const -- cgit