forked from qt-creator/qt-creator
TreeModel: Make root item configurable
This is mainly used to communicate the number of columns and header contents. Change-Id: Ic3163265338d71f1fa8250e4765bb764e5784197 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -198,6 +198,14 @@ QVariant TreeModel::data(const QModelIndex &idx, int role) const
|
||||
return item ? item->data(idx.column(), role) : QVariant();
|
||||
}
|
||||
|
||||
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal)
|
||||
return m_root->data(section, role);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags TreeModel::flags(const QModelIndex &idx) const
|
||||
{
|
||||
TreeItem *item = itemFromIndex(idx);
|
||||
@@ -210,6 +218,12 @@ TreeItem *TreeModel::rootItem() const
|
||||
return m_root;
|
||||
}
|
||||
|
||||
void TreeModel::setRootItem(TreeItem *item)
|
||||
{
|
||||
delete m_root;
|
||||
m_root = item;
|
||||
}
|
||||
|
||||
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
checkIndex(parent);
|
||||
|
||||
Reference in New Issue
Block a user