44 if(!parent.isValid()) {
45 return createIndex(row, column,
_root);
53 if(parent.column() > 0)
62 return createIndex(row, column, childItem);
77 if(parentItem == NULL)
80 return createIndex(childItem->
row(), 0, parentItem);
88 if(index.column() == 1) {
97 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
99 if(index.column() == 1) {
102 if(item->
isBool(index.row(), index.column())) {
103 flags |= Qt::ItemIsUserCheckable;
105 flags |= Qt::ItemIsEditable;
114 if (!index.isValid())
118 if(role != Qt::DisplayRole && role != Qt::CheckStateRole && role != Qt::EditRole)
123 if(role == Qt::CheckStateRole) {
124 if(!item->
isBool(index.row(), index.column()))
129 return item->
data(index.row(), index.column()).toBool() ? Qt::Checked : Qt::Unchecked;
132 if(role == Qt::DisplayRole) {
133 if(item->
isBool(index.row(), index.column()))
136 QVariant itemDisplay = item->
data(index.row(), index.column());
137 if(itemDisplay.type() != QVariant::String) {
141 QString itemStr = itemDisplay.toString();
145 if(itemStr.length() > (int)maxLength) {
146 itemStr = itemStr.mid(0, maxLength - 3) +
"...";
152 if(role == Qt::EditRole) {
153 return item->
data(index.row(), index.column());
164 if(role != Qt::EditRole && role != Qt::CheckStateRole)
167 if(index.column() != 1)
171 if(parentItem->
isBool(index.row(), index.column())) {
172 if(role == Qt::EditRole)
175 if(!parentItem->
isBool(index.row(), index.column())) {
176 if(role == Qt::CheckStateRole)
184 Q_EMIT dataChanged(index, index);
193 if(role != Qt::DisplayRole || orientation != Qt::Horizontal)
206 if(!parent.isValid()) {
210 if(parent.column() > 0)
225 if(!parent.isValid()) {
231 if(parent.column() > 0)
unsigned int _maxDisplayLength
A wrapper around the XmlRpcValue including a parent pointer and convenience functions for the qt mode...
XmlRpcModel(XmlRpc::XmlRpcValue *rootData, const std::string &rootPath, ros::NodeHandle *nh)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
XmlRpcTreeItem * parent()
QModelIndex parent(const QModelIndex &index) const
bool setData(QVariant val)
set data for this item
int rowCount(const QModelIndex &parent=QModelIndex()) const
should return the number of children for a parent item
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
Qt::ItemFlags flags(const QModelIndex &index) const
bool isBool(int row, int column) const
is the stored data a bool
QVariant data(int row, int column) const
return the data in the map
XmlRpcTreeItem * child(unsigned int i)
int row() const
Figure out which row/nth child we are for the parent.
QVariant data(const QModelIndex &index, int role) const
unsigned int childCount() const