48 QItemSelectionModel::SelectionFlags command)
50 QModelIndex property_index = index.sibling(index.row(), 1);
51 if (index.flags() & Qt::ItemIsEditable || !property_index.isValid())
53 QItemSelectionModel::setCurrentIndex(index, command);
57 QItemSelectionModel::setCurrentIndex(property_index, command);
62 : QTreeView(parent), model_(nullptr), splitter_handle_(new
SplitterHandle(this))
65 setDropIndicatorShown(
true);
66 setUniformRowHeights(
true);
67 setHeaderHidden(
true);
71 setAllColumnsShowFocus(
true);
72 setSelectionMode(QAbstractItemView::ExtendedSelection);
73 setEditTriggers(QAbstractItemView::AllEditTriggers);
75 QTimer* timer =
new QTimer(
this);
76 connect(timer, SIGNAL(timeout()),
this, SLOT(
update()));
81 const QModelIndex& previous_current_index)
83 QTreeView::currentChanged(new_current_index, previous_current_index);
88 const QItemSelection& deselected)
90 QTreeView::selectionChanged(selected, deselected);
100 disconnect(
model_, SIGNAL(expand(
const QModelIndex&)),
this, SLOT(expand(
const QModelIndex&)));
101 disconnect(
model_, SIGNAL(collapse(
const QModelIndex&)),
this, SLOT(collapse(
const QModelIndex&)));
104 QTreeView::setModel(
model_);
107 QItemSelectionModel* m = selectionModel();
113 connect(
model_, SIGNAL(expand(
const QModelIndex&)),
this, SLOT(expand(
const QModelIndex&)));
114 connect(
model_, SIGNAL(collapse(
const QModelIndex&)),
this, SLOT(collapse(
const QModelIndex&)));
137 const QModelIndex& parent_index,
138 const QString& prefix)
const 141 if (num_children > 0)
143 QHash<QString, int> name_counts;
144 for (
int i = 0; i < num_children; i++)
146 QModelIndex child_index =
model_->
index(i, 0, parent_index);
148 QString child_name = child->
getName();
149 if (qobject_cast<StatusList*>(child))
153 child_name =
"Status";
155 int name_occurrence = ++(name_counts[child_name]);
156 QString full_name = prefix +
"/" + child_name + QString::number(name_occurrence);
157 if (isExpanded(child_index))
169 QSet<QString> expanded_full_names;
170 int num_expanded = expanded_list_config.
listLength();
171 for (
int i = 0; i < num_expanded; i++)
185 const QModelIndex& parent_index,
186 const QString& prefix)
189 if (num_children > 0)
191 QHash<QString, int> name_counts;
192 for (
int i = 0; i < num_children; i++)
194 QModelIndex child_index =
model_->
index(i, 0, parent_index);
196 QString child_name = child->
getName();
197 if (qobject_cast<StatusList*>(child))
199 child_name =
"Status";
201 int name_occurrence = ++(name_counts[child_name]);
202 QString full_name = prefix +
"/" + child_name + QString::number(name_occurrence);
203 if (expanded_full_names.contains(full_name))
205 setExpanded(child_index,
true);
void setValue(const QVariant &value)
Ensures this is a valid Config object, sets the type to Value then sets the value.
float getRatio()
Get the ratio of the parent's left column to the parent widget width.
QVariant getValue() const
If this config object is valid and is a Value type, this returns its value. Otherwise it returns an i...
QModelIndex parentIndex(const Property *child) const
Same as parent() but taking a Property pointer instead of an index.
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of rows under the given parent index.
A single element of a property tree, with a name, value, description, and possibly children...
PropertySelectionModel(QAbstractItemModel *model=nullptr)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
int listLength() const
Returns the length of the List in this Node, or 0 if this Node does not have type List...
A tall skinny invisible widget providing left-right sliding column separator adjustment for a two-col...
Config mapGetChild(const QString &key) const
If the referenced Node is a Map and it has a child with the given key, return a reference to the chil...
PropertyTreeModel * getModel() const
Return the model managing this Property and its childrent.
int rowNumberInParent() const
Return the row number of this property within its parent, or -1 if it has no parent.
void mapSetValue(const QString &key, QVariant value)
Set a named child to the given value.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
Configuration data storage class.
void setModel(PropertyTreeModel *model)
Set the model managing this Property and all its child properties, recursively.
Property * getRoot() const
Property * getProp(const QModelIndex &index) const
return the Property at the given index, or the root property if the index is invalid.
virtual QString getName() const
Return the name of this Property as a QString.
Config mapMakeChild(const QString &key)
Create a child node stored with the given key, and return the child.
bool mapGetFloat(const QString &key, float *value_out) const
Convenience function for looking up a named float.
Config listAppendNew()
Ensure the referenced Node is of type List, append a new Empty Node to the end of the list...
Config listChildAt(int i) const
Return the i'th child in the list, if the referenced Node has type List. Returns an Invalid Config if...
void setRatio(float ratio)
Set the ratio of the parent's left column to the parent widget width.