21 if (index.isValid()) {
23 QModelIndex cur = index;
24 while (cur.isValid()) {
25 namePath << cur.data().toString();
28 std::reverse(namePath.begin(), namePath.end());
29 return namePath.join(
"/");
39 QStringList parts = path.split(
"/");
41 for (
int i = 0; i < parts.length(); i++) {
42 if (t->
modelType() ==
"JobItem" && parts[i] ==
"GISASInstrument") {
71 for (
int i_row = 0; i_row < model->
rowCount(parent); ++i_row) {
72 QModelIndex index = model->
index(i_row, 0, parent);
90 while (cur && cur->
modelType() != requiredModelType)
100 QStringList pathList;
102 while (current && current != topItem) {
104 current = current->
parent();
106 std::reverse(pathList.begin(), pathList.end());
107 return pathList.join(
"/");
#define ASSERT(condition)
Defines ModelPath namespace.
Defines class SessionModel.
static const QString T_INSTRUMENT
QString itemName() const
Get item name, return display name if no name is set.
int numberOfChildren() const
Returns total number of children.
virtual QStringList translateList(const QStringList &list) const
SessionItem * parent() const
Returns parent of this item.
SessionModel * model() const
Returns model of this item.
SessionItem * childAt(int row) const
Returns the child at the given row.
QString modelType() const
Get model type.
QModelIndex index() const
Returns model index of this item.
SessionItem * getItem(const QString &tag="", int row=0) const
Returns item in given row of given tag.
SessionItem * itemForIndex(const QModelIndex &index) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
virtual int rowCount(const QModelIndex &parent) const
SessionItem * rootItem() const
SessionItem * getItemFromPath(const QString &relPath, const SessionItem *parent)
returns an item from relative path wrt to given parent
QModelIndex getIndexFromPath(const SessionModel *model, const QString &path)
bool isValidItem(SessionModel *model, SessionItem *item, const QModelIndex &parent)
Iterates through all the model and returns true if item is found. This is to.
const SessionItem * ancestor(const SessionItem *item, const QString &requiredModelType)
Returns ancestor of given modelType for given item.
QString getPathFromIndex(const QModelIndex &index)
QString itemPathTranslation(const SessionItem &item, const SessionItem *topItem=0)
Returns translation of item path to domain name.