Commit 036f4f00 authored by hjk's avatar hjk
Browse files

TreeModel: Add a TreeItem::setData function

Change-Id: Id59c35068cd5a2ba22ccfddd45a0826dd68e9905
Reviewed-by: default avatarChristian Stenger <>
parent b3f0a1bf
......@@ -662,6 +662,14 @@ QVariant TreeItem::data(int column, int role) const
return QVariant();
bool TreeItem::setData(int column, const QVariant &data, int role)
return false;
Qt::ItemFlags TreeItem::flags(int column) const
......@@ -785,6 +793,15 @@ int TreeModel::columnCount(const QModelIndex &idx) const
return itemFromIndex(idx)->columnCount();
bool TreeModel::setData(const QModelIndex &idx, const QVariant &data, int role)
TreeItem *item = itemFromIndex(idx);
bool res = item ? item->setData(idx.column(), data, role) : false;
if (res)
emit dataChanged(idx, idx);
return res;
QVariant TreeModel::data(const QModelIndex &idx, int role) const
TreeItem *item = itemFromIndex(idx);
......@@ -58,6 +58,7 @@ public:
virtual void populate();
virtual QVariant data(int column, int role) const;
virtual bool setData(int column, const QVariant &data, int role);
virtual Qt::ItemFlags flags(int column) const;
void prependChild(TreeItem *item);
......@@ -220,6 +221,7 @@ public:
int rowCount(const QModelIndex &idx = QModelIndex()) const;
int columnCount(const QModelIndex &idx) const;
bool setData(const QModelIndex &idx, const QVariant &data, int role);
QVariant data(const QModelIndex &idx, int role) const;
QModelIndex index(int, int, const QModelIndex &idx) const;
QModelIndex parent(const QModelIndex &idx) const;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment