void TreeModel::redrawArray(const QModelIndex arrayIndex){ if(Teuchos::toString(itemEntry(arrayIndex)->getAny()).size() <= 2){ emit hideData(arrayIndex.row(), arrayIndex.parent()); } else{ setData(arrayIndex, QString::fromStdString(Teuchos::toString(itemEntry(arrayIndex)->getAny()))); emit showData(arrayIndex.row(), arrayIndex.parent()); } }
void TreeModel::dataChangedListener(const QModelIndex& index1, const QModelIndex& /*index2*/){ const Teuchos::ParameterEntry* changedIndexEntry = itemEntry(index1); QModelIndex dependee = index1.sibling(index1.row(), 0); if(dependencySheet->hasDependents(changedIndexEntry)){ DependencySheet::DepSet deps = dependencySheet->getDependenciesForParameter(changedIndexEntry); for(DependencySheet::DepSet::iterator it = deps.begin(); it != deps.end(); ++it){ (*it)->evaluate(); checkDependentState(dependee,*it); } } }
QModelIndex TreeModel::findParameterEntryIndex(const Teuchos::ParameterEntry *parameterEntry, const std::string parameterName){ QString targetName = QString::fromStdString(parameterName); QList<QModelIndex> potentialMatches = match(index(0,0), Qt::DisplayRole, QString::fromStdString(parameterName), -1, Qt::MatchExactly | Qt::MatchRecursive ); for(QList<QModelIndex>::const_iterator it = potentialMatches.begin(); it != potentialMatches.end(); ++it){ if(parameterEntry == itemEntry(*it)){ return *it; } } return QModelIndex(); }
Json::Value Inventory::serialize() const { Json::Value inventoryNode(Json::arrayValue); for(const auto& iter : m_items) { int itemNumber = iter.first; int itemQuantity = iter.second; if(itemQuantity > 0) { Json::Value itemEntry(Json::objectValue); itemEntry[Inventory::ITEM_NUM_ATTRIBUTE] = itemNumber; itemEntry[Inventory::ITEM_QUANTITY_ATTRIBUTE] = itemQuantity; inventoryNode.append(itemEntry); } } return inventoryNode; }
Teuchos::RCP<const Teuchos::ParameterEntryValidator> TreeModel::getValidator(const QModelIndex &index) const{ return itemEntry(index)->validator(); }