Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
int RegExpModel::rowCount(const QModelIndex &parent) const
{
    Node *parentNode = nodeFromIndex(parent);
    if (!parentNode)
        return 0;
    return parentNode->children.count();
}
Exemplo n.º 3
0
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();
}
Exemplo n.º 4
0
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();
}
Exemplo n.º 5
0
// 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();
}
Exemplo n.º 6
0
// 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;
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
/**
 * 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;
}
Exemplo n.º 9
0
/**
 * 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));
}
Exemplo n.º 10
0
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;
      }
Exemplo n.º 11
0
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();
      }
Exemplo n.º 12
0
void OperationsModel::onDataChanged(const QModelIndex &index)
      {
      Node *node = nodeFromIndex(index);
      if (!node)
            return;
      if (controller->updateNodeDependencies(node, false))
            layoutChanged();
      }
Exemplo n.º 13
0
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]);
}
Exemplo n.º 14
0
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]);
}
Exemplo n.º 15
0
int DicomHierarchyModel::rowCount ( const QModelIndex & parent) const {

    AbstractDicomHierarchyNode *node = nodeFromIndex(parent);

    if (!node)
        return 0;

    return node->children_.count();
}
Exemplo n.º 16
0
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();	
}
Exemplo n.º 17
0
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;
}
Exemplo n.º 18
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();
}
Exemplo n.º 19
0
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();
}
Exemplo n.º 20
0
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);
}
Exemplo n.º 21
0
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);
}
Exemplo n.º 22
0
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();
}
Exemplo n.º 23
0
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);
}
Exemplo n.º 24
0
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);
}
Exemplo n.º 25
0
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);
}
Exemplo n.º 26
0
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;
}
Exemplo n.º 27
0
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;
}
Exemplo n.º 28
0
/**
 * 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);
}
Exemplo n.º 29
0
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;
}
Exemplo n.º 30
0
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();
}