QVariant MyTreeZoneModel::data(const QModelIndex &index, int role) const{ if(role == Qt::CheckStateRole) { return nodeFromIndex(index)->getDisplayed(); } if(role != Qt::DisplayRole) return QVariant(); Zone *node = nodeFromIndex(index); if(!node) return QVariant(); return node->getLable(); }
int RegExpModel::rowCount(const QModelIndex &parent) const { Node *parentNode = nodeFromIndex(parent); if (!parentNode) return 0; return parentNode->children.count(); }
QVariant BooleanModel::data(const QModelIndex &index, int role) const { if (role != Qt::DisplayRole) return QVariant(); Node *node = nodeFromIndex(index); if (!node) return QVariant(); if (index.column() == 0) { switch (node->type) { case Node::Root: return tr("Root"); case Node::OrExpression: return tr("OR Expression"); case Node::AndExpression: return tr("AND Expression"); case Node::NotExpression: return tr("NOT Expression"); case Node::Atom: return tr("Atom"); case Node::Identifier: return tr("Identifier"); case Node::Operator: return tr("Operator"); case Node::Punctuator: return tr("Punctuator"); default: return tr("Unknown"); } } else if (index.column() == 1) { return node->str; } return QVariant(); }
QVariant RegExpModel::data(const QModelIndex &index, int role) const { if (role != Qt::DisplayRole) return QVariant(); Node *node = nodeFromIndex(index); if (!node) return QVariant(); if (index.column() == 0) { switch (node->type) { case Node::RegExp: return tr("RegExp"); case Node::Expression: return tr("Expression"); case Node::Term: return tr("Term"); case Node::Factor: return tr("Factor"); case Node::Atom: return tr("Atom"); case Node::Terminal: return tr("Terminal"); default: return tr("Unknown"); } } else if (index.column() == 1) { return node->str; } return QVariant(); }
// virtual QModelIndex CQTaskMethodParametersDM::index(int row, int column, const QModelIndex & parent) const { CCopasiParameterGroup * pParent = static_cast< CCopasiParameterGroup * >(nodeFromIndex(parent)); if (pParent == NULL && mMethods.size() > 0) { QVector< CCopasiMethod * >::const_iterator it = mMethods.constBegin(); QVector< CCopasiMethod * >::const_iterator end = mMethods.constEnd(); int Row = row; for (; it != end; ++it) if (Row < (int)(*it)->size()) { return createIndex(row, column, *((*it)->beginIndex() + Row)); } else { Row -= (int)(*it)->size(); } return QModelIndex(); } if (pParent != NULL && row < (int) pParent->size()) return createIndex(row, column, *(pParent->beginIndex() + row)); else return QModelIndex(); }
// virtual int CQTaskMethodParametersDM::rowCount(const QModelIndex & parent) const { if (!parent.isValid()) { QVector< CCopasiMethod * >::const_iterator it = mMethods.constBegin(); QVector< CCopasiMethod * >::const_iterator end = mMethods.constEnd(); int size = 0; for (; it != end; ++it) size += (int)(*it)->size(); return size; } CCopasiParameter * pParent = nodeFromIndex(parent); switch (pParent->getType()) { case CCopasiParameter::GROUP: return (int) static_cast< CCopasiParameterGroup * >(pParent)->size(); break; default: break; } return 0; }
// virtual bool CQTaskMethodParametersDM::setData(const QModelIndex &_index, const QVariant &value, int role) { CCopasiParameter * pNode = nodeFromIndex(_index); if (pNode == NULL) return false; bool success = false; if (role == Qt::EditRole || role == Qt::CheckStateRole) { switch (_index.column()) { case COL_VALUE: success = setParameterValue(pNode, value); break; default: success = true; break; } } return success; }
/** * Modifies a style's property. * The method updates the property to which the index corresponds, as well as * the same property for all child styles that inherit this property. * @param index Corresponds to a property node * @param value The new value to set * @param role Must be Qt::EditRole * @return true if the property was updated, false otherwise */ bool LexerStyleModel::setData(const QModelIndex& index, const QVariant& value, int role) { // Can only modify property nodes. Node* node = nodeFromIndex(index); if (!node || !node->data() || !node->data()->type() == PropertyNode) return false; if (role != Qt::EditRole) return false; // Set the property's value. PropertyData* data = static_cast<PropertyData*>(node->data()); Node* styleNode = data->styleNode_; setProperty(value, styleNode, data->prop_, QVariant()); // Update changes. emit dataChanged(index, index); QModelIndex styleIndex = createIndex(styleNode->index(), 1, styleNode); emit dataChanged(styleIndex, styleIndex); // Apply property to inheriting styles. inheritProperty(value, styleNode, data->prop_, false); return true; }
/** * Creates an index. * @param row The row of the index, relative to the parent * @param column The column of the index * @param parent The parent index. * @return The resulting index */ QModelIndex LexerStyleModel::index(int row, int column, const QModelIndex& parent) const { const Node* node = nodeFromIndex(parent); if (node == NULL) return QModelIndex(); // Root nodes do not have data. if (node->data() == NULL) return createIndex(row, column, (void*)node->child(row)); // Property nodes do not have children. if (node->data()->type() == PropertyNode) return QModelIndex(); // For column 2 on a style node, return an index representing the root // property node. if (column == 2) { StyleData* style = static_cast<StyleData*>(node->data()); return createIndex(row, column, (void*)&style->propRoot_); } // Return an index representing a child style. return createIndex(row, column, (void*)node->child(row)); }
bool OperationsModel::setData(const QModelIndex &index, const QVariant &value, int role) { Node *node = nodeFromIndex(index); if (!node) return false; bool result = false; if (index.column() == OperationCol::VALUE) { switch (role) { case Qt::CheckStateRole: node->oper.value = value.toBool(); result = true; break; case Qt::EditRole: // set enum value from value == list index node->oper.value = value.toInt(); result = true; break; default: break; } } if (result) emit dataChanged(index, index); return result; }
QVariant OperationsModel::data(const QModelIndex &index, int role) const { const Node *node = nodeFromIndex(index); if (!node) return QVariant(); switch (role) { case DataRole: if (node->values.empty()) // checkbox return node->oper.value.toBool(); else return node->oper.value.toInt(); break; case Qt::DisplayRole: switch (index.column()) { case OperationCol::OPER_NAME: return node->name; case OperationCol::VALUE: if (!node->values.empty()) { if (!node->oper.value.isValid()) // undefined operation value return " . . . "; // list contains names of possible string values // like {"1/4", "1/8"} // valid node value is one of enum items // -> use enum item as index int indexOfValue = node->oper.value.toInt(); if (indexOfValue < node->values.size() && indexOfValue >= 0) return node->values.at(indexOfValue); } // otherwise return nothing because it's a checkbox break; default: break; } break; case Qt::EditRole: if (index.column() == OperationCol::VALUE && !node->values.empty()) return node->values; break; case Qt::CheckStateRole: if (index.column() == OperationCol::VALUE && node->values.empty()) { if (!node->oper.value.isValid()) return Qt::PartiallyChecked; return (node->oper.value.toBool()) ? Qt::Checked : Qt::Unchecked; } break; case Qt::SizeHintRole: { QSize sz; sz.setHeight(22); return sz; } case OperationTypeRole: return (int)node->oper.type; default: break; } return QVariant(); }
void OperationsModel::onDataChanged(const QModelIndex &index) { Node *node = nodeFromIndex(index); if (!node) return; if (controller->updateNodeDependencies(node, false)) layoutChanged(); }
QModelIndex RegExpModel::index(int row, int column, const QModelIndex &parent) const { if (!rootNode) return QModelIndex(); Node *parentNode = nodeFromIndex(parent); return createIndex(row, column, parentNode->children[row]); }
QModelIndex DicomHierarchyModel::index(int row, int column, const QModelIndex &parent) const { if (!rootNode_) return QModelIndex(); AbstractDicomHierarchyNode *parentNode = nodeFromIndex(parent); return createIndex(row, column, parentNode->children_[row]); }
int DicomHierarchyModel::rowCount ( const QModelIndex & parent) const { AbstractDicomHierarchyNode *node = nodeFromIndex(parent); if (!node) return 0; return node->children_.count(); }
int BooleanModel::rowCount(const QModelIndex& parent) const { if (parent.column() > 0) return 0; Node* parentNode = nodeFromIndex(parent); if (!parentNode) return 0; return parentNode->children.count(); }
int SiteListItemModel::rowCount(const QModelIndex& parent) const { if(parent.column() > 0) return 0; SiteListItem* parentItem = nodeFromIndex(parent); if(parentItem) { return parentItem->children()->count(); } return 0; }
int ScriptEngineModel::rowCount(const QModelIndex& parent) const { if (!m_rootNode) return 0; ScriptEngineNode* parentNode; if (parent.isValid()) parentNode = nodeFromIndex(parent); else parentNode = m_rootNode; return parentNode->childCount(); }
int DataSourceModel::rowCount(const QModelIndex& parent) const { if (!m_rootNode) return 0; DataNode* parentNode; if (parent.isValid()) parentNode = nodeFromIndex(parent); else parentNode = m_rootNode; return parentNode->childCount(); }
void QScriptDebuggerLocalsModelPrivate::syncIndex(const QModelIndex &index) { if (!index.isValid()) return; QScriptDebuggerLocalsModelNode *node = nodeFromIndex(index); if (node->populationState != QScriptDebuggerLocalsModelNode::Populated) return; QScriptDebuggerJob *job = new SyncModelIndexJob(index, commandScheduler); jobScheduler->scheduleJob(job); }
QModelIndex MyTreeZoneModel::index(int row, int column, const QModelIndex &parent) const{ if(!rootNode || row < 0 || column < 0) return QModelIndex(); Groupe_selection *parentNode = nodeFromIndex(parent); Zone *childNode = parentNode->getZones().value(row); if(!childNode) return QModelIndex(); return createIndex(row, column, childNode); }
int MyTreeZoneModel::rowCount(const QModelIndex &parent) const{ if(parent.column() > 0) return 0; Groupe_selection *parentNode =nodeFromIndex(parent); if(parentNode->getType() != Zone::composite) return 0; if(!parentNode) return 0; return parentNode->getZones().count(); }
QModelIndex ScriptEngineModel::parent(const QModelIndex& child) const { if (!child.isValid()) return QModelIndex(); ScriptEngineNode* childNode = nodeFromIndex(child); if (!childNode) return QModelIndex(); ScriptEngineNode* parentNode = childNode->parent(); if ((parentNode == m_rootNode) || (!parentNode)) return QModelIndex(); return createIndex(parentNode->row(),0,parentNode); }
QModelIndex BooleanModel::index(int row, int column, const QModelIndex &parent) const { if (!rootNode || row < 0 || column < 0) return QModelIndex(); Node *parentNode = nodeFromIndex(parent); Node *childNode = parentNode->children.value(row); if (!childNode) return QModelIndex(); return createIndex(row, column, childNode); }
void QScriptDebuggerLocalsModelPrivate::reallyPopulateIndex( const QModelIndex &index, const QScriptDebuggerValuePropertyList &props) { if (!index.isValid()) return; QScriptDebuggerLocalsModelNode *node = nodeFromIndex(index); Q_ASSERT(node->populationState == QScriptDebuggerLocalsModelNode::Populating); node->populationState = QScriptDebuggerLocalsModelNode::Populated; addChildren(index, node, props); }
bool DicomHierarchyModel::canFetchMore ( const QModelIndex & parent ) const { if (!parent.isValid()) return false; AbstractDicomHierarchyNode* node = nodeFromIndex(parent); if (!node || node->type_ == AbstractDicomHierarchyNode::SERIES) return false; return true; }
bool DicomHierarchyModel::hasChildren ( const QModelIndex & parent) const { AbstractDicomHierarchyNode* node = nodeFromIndex(parent); if (!node) return false; if (node->type_ == AbstractDicomHierarchyNode::SERIES) return false; else return true; }
/** * Forces all child styles to inherit the given property. * @param index Corresponds to a property node in the parent style */ void LexerStyleModel::applyInheritance(const QModelIndex& index) { // Ensure the index corresponds to a property node. Node* node = nodeFromIndex(index); if ((node == NULL) || (node->data() == NULL) || (node->data()->type() != PropertyNode)) { return; } // Apply inheritance to child styles. PropertyData* data = static_cast<PropertyData*>(node->data()); inheritProperty(data->value_, data->styleNode_, data->prop_, true); }
bool SiteListItemModel::removeRows(int row, int count, const QModelIndex& index) { beginRemoveRows(index, row, row+count-1); SiteListItem* node = nodeFromIndex(index); if(node) { for(int i=0; i<count; i++) { node->removeChild(row+i); } endRemoveRows(); return true; } endRemoveRows(); return false; }
QVariant DicomHierarchyModel::data(const QModelIndex &index, int role) const { if (role != Qt::DisplayRole) return QVariant(); AbstractDicomHierarchyNode *node = nodeFromIndex(index); if (!node) return QVariant(); return node->getDataString(); }