//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifEclipseDataTableFormatter::outputBuffer() { if (!m_columns.empty() && !isAllHeadersEmpty(m_columns)) { m_out << m_commentPrefix; for (size_t i = 0u; i < m_columns.size(); ++i) { m_out << formatColumn(m_columns[i].title, i); } m_out << "\n"; } for (auto line : m_buffer) { if (line.lineType == COMMENT) { outputComment(line); } else if (line.lineType == HORIZONTAL_LINE) { outputHorizontalLine(line); } else if (line.lineType == CONTENTS) { QString lineText = m_tableRowPrependText; bool isComment = m_tableRowPrependText.startsWith(m_commentPrefix); QString appendText = (line.appendTextSet ? line.appendText : m_tableRowAppendText); for (size_t i = 0; i < line.data.size(); ++i) { QString column = formatColumn(line.data[i], i); QString newLineText = lineText + column; if (i == line.data.size() - 1) { newLineText += appendText; } if (!isComment && newLineText.length() > maxDataRowWidth()) { m_out << lineText << "\n"; lineText = m_tableRowPrependText; } lineText += column; } m_out << lineText << appendText << "\n"; } } m_columns.clear(); m_buffer.clear(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- int RifEclipseDataTableFormatter::tableWidth() const { int characterCount = m_tableRowPrependText.length(); for (size_t i = 0u; i < m_columns.size(); ++i) { characterCount += formatColumn(" ", i).size(); } characterCount += m_tableRowAppendText.length(); return characterCount; }
//----------------------------------------------------------------------------- // Function: ParameterDelegate::setEditorData() //----------------------------------------------------------------------------- void ParameterDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const { if (index.column() == valueColumn() && valueIsArray(index)) { ArrayView* view = dynamic_cast<ArrayView*>(dynamic_cast<QScrollArea*>(editor)->widget()); QModelIndex arrayLeftIndex = index.sibling(index.row(), arrayLeftColumn()); int arrayLeftValue = arrayLeftIndex.data(Qt::ToolTipRole).toInt(); QModelIndex arrayRightIndex = index.sibling(index.row(), arrayRightColumn()); int arrayRightValue = arrayRightIndex.data(Qt::ToolTipRole).toInt(); int arraySize = getArraySize(arrayLeftValue, arrayRightValue); int arrayStartIndex = arrayLeftValue; if (arrayRightValue < arrayLeftValue) { arrayStartIndex = arrayRightValue; } QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser( getParameterFinder())); QSharedPointer<Choice> selectedChoice = findChoice(index); ParameterArrayModel* model = new ParameterArrayModel(arraySize, expressionParser, getParameterFinder(), expressionFormatter_, selectedChoice, QColor("LemonChiffon"), arrayStartIndex, view); QModelIndex valueIndex = index.sibling(index.row(), valueColumn()); QString parameterValue = valueIndex.data(Qt::EditRole).toString(); model->setArrayData(parameterValue); QModelIndex typeIndex = index.sibling(index.row(), formatColumn()); QString parameterType = typeIndex.data(Qt::EditRole).toString(); model->setParameterType(parameterType); view->setItemDelegate(new ArrayDelegate(getNameCompleter(), getParameterFinder(), selectedChoice, this->parent())); view->setModel(model); view->setSortingEnabled(false); view->resizeColumnsToContents(); connect(model, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection); connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(contentChanged()), Qt::UniqueConnection); connect(view->itemDelegate(), SIGNAL(increaseReferences(QString)), this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection); connect(view->itemDelegate(), SIGNAL(decreaseReferences(QString)), this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection); }
//----------------------------------------------------------------------------- // Function: ParameterDelegate::createEditor() //----------------------------------------------------------------------------- QWidget* ParameterDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index ) const { if (index.column() == nameColumn()) { QWidget* editor = QStyledItemDelegate::createEditor(parent, option, index); QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor); if (lineEditor) { lineEditor->setValidator(new NameValidator(lineEditor)); } return editor; } if (index.column() == choiceColumn()) { return createChoiceSelector(parent); } else if (index.column() == formatColumn()) { return createFormatSelector(parent); } else if (index.column() == resolveColumn()) { return createResolveSelector(parent); } else if (index.column() == usageCountColumn()) { QModelIndex valueIdIndex = index.sibling(index.row(), idColumn()); QString targetId = valueIdIndex.data(Qt::DisplayRole).toString(); emit(openReferenceTree(targetId)); return 0; } else if (index.column() == valueColumn() && valueIsArray(index)) { ArrayView* editor = new ArrayView(parent); QScrollArea* scrollingWidget = new QScrollArea(parent); scrollingWidget->setWidgetResizable(true); scrollingWidget->setWidget(editor); scrollingWidget->parent()->installEventFilter(editor); return scrollingWidget; } else if (isIndexForValueUsingChoice(index)) { return createEnumerationSelector(parent, index); } else if (index.column() == descriptionColumn()) { QTextEdit* editor = new QTextEdit(parent); editor->setMinimumHeight(120); return editor; } else { return ChoiceCreatorDelegate::createEditor(parent, option, index); } }