diff -r 133e2ed6b9c5 -r f1006de05c54 treemodel.cpp --- a/treemodel.cpp Thu Sep 03 08:52:00 2009 +0000 +++ b/treemodel.cpp Mon Sep 07 15:36:57 2009 +0000 @@ -15,7 +15,7 @@ { QList rootData; rootData << "Heading" << "Type"; - rootItem = new TreeItem(rootData); + rootItem = new BranchItem(rootData); } TreeModel::~TreeModel() @@ -39,7 +39,7 @@ Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return Qt::ItemIsEnabled; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } @@ -58,23 +58,26 @@ if (!ti->parent()) return QModelIndex(); else - return createIndex (ti->row(),ti->column(),ti); + return createIndex (ti->row(),0,ti); } QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const { + // Make sure to return invalid index for invalid values (see modeltest) + if (row<0 || column<0) return QModelIndex(); + if (column!=0) return QModelIndex(); + TreeItem *parentItem; if (!parent.isValid()) - { //FIXME-3 left here for testing only, seems to work now... + { parentItem = rootItem; /* cout << "TM::index() no parent?! xxx\n"; cout << " row="<getHeadingStd(); @@ -224,6 +237,8 @@ ti=pi->getChildNum (row); cout << " pi="<