void ChangeSet::convertToReplace(const EditOp &op, QList<EditOp> *replaceList) { EditOp replace1(EditOp::Replace); EditOp replace2(EditOp::Replace); switch (op.type) { case EditOp::Replace: replaceList->append(op); break; case EditOp::Move: replace1.pos1 = op.pos1; replace1.length1 = op.length1; replaceList->append(replace1); replace2.pos1 = op.pos2; replace2.text = textAt(op.pos1, op.length1); replaceList->append(replace2); break; case EditOp::Insert: replace1.pos1 = op.pos1; replace1.text = op.text; replaceList->append(replace1); break; case EditOp::Remove: replace1.pos1 = op.pos1; replace1.length1 = op.length1; replaceList->append(replace1); break; case EditOp::Flip: replace1.pos1 = op.pos1; replace1.length1 = op.length1; replace1.text = textAt(op.pos2, op.length2); replaceList->append(replace1); replace2.pos1 = op.pos2; replace2.length1 = op.length2; replace2.text = textAt(op.pos1, op.length1); replaceList->append(replace2); break; case EditOp::Copy: replace1.pos1 = op.pos2; replace1.text = textAt(op.pos1, op.length1); replaceList->append(replace1); break; case EditOp::Unset: break; } }
QVariant SimpleAbstractStreamReader::parsePropertyExpression(AST::ExpressionNode *expressionNode) { Q_ASSERT(expressionNode); AST::ArrayLiteral *arrayLiteral = AST::cast<AST::ArrayLiteral *>(expressionNode); if (arrayLiteral) { QList<QVariant> variantList; for (AST::ElementList *it = arrayLiteral->elements; it; it = it->next) variantList << parsePropertyExpression(it->expression); return variantList; } AST::StringLiteral *stringLiteral = AST::cast<AST::StringLiteral *>(expressionNode); if (stringLiteral) return stringLiteral->value.toString(); AST::TrueLiteral *trueLiteral = AST::cast<AST::TrueLiteral *>(expressionNode); if (trueLiteral) return true; AST::FalseLiteral *falseLiteral = AST::cast<AST::FalseLiteral *>(expressionNode); if (falseLiteral) return false; AST::NumericLiteral *numericLiteral = AST::cast<AST::NumericLiteral *>(expressionNode); if (numericLiteral) return numericLiteral->value; return textAt(expressionNode->firstSourceLocation(), expressionNode->lastSourceLocation()); }
QString CMakeEditor::contextHelpId() const { int pos = position(); QChar chr; do { --pos; if (pos < 0) break; chr = characterAt(pos); if (chr == QLatin1Char('(')) return QString(); } while (chr.unicode() != QChar::ParagraphSeparator); ++pos; chr = characterAt(pos); while (chr.isSpace()) { ++pos; chr = characterAt(pos); } int begin = pos; do { ++pos; chr = characterAt(pos); } while (chr.isLetterOrNumber() || chr == QLatin1Char('_')); int end = pos; while (chr.isSpace()) { ++pos; chr = characterAt(pos); } // Not a command if (chr != QLatin1Char('(')) return QString(); QString command = textAt(begin, end - begin).toLower(); return QLatin1String("command/") + command; }
/** * \brief Save the column as XML */ void Column::save(QXmlStreamWriter* writer) const { writer->writeStartElement("column"); writeBasicAttributes(writer); writer->writeAttribute("mode", QString::number(columnMode())); writer->writeAttribute("width", QString::number(width())); //save the formula used to generate column values, if available if (!formula().isEmpty() ) { writer->writeStartElement("formula"); writer->writeTextElement("text", formula()); writer->writeStartElement("variableNames"); for (int i=0; i<formulaVariableNames().size(); ++i) { writer->writeTextElement("name", formulaVariableNames().at(i)); } writer->writeEndElement(); writer->writeStartElement("columnPathes"); for (int i=0; i<formulaVariableColumnPathes().size(); ++i) { writer->writeTextElement("path", formulaVariableColumnPathes().at(i)); } writer->writeEndElement(); writer->writeEndElement(); } writeCommentElement(writer); writer->writeStartElement("input_filter"); m_column_private->inputFilter()->save(writer); writer->writeEndElement(); writer->writeStartElement("output_filter"); m_column_private->outputFilter()->save(writer); writer->writeEndElement(); //TODO: formula in cells is not implemented yet // XmlWriteMask(writer); // QList< Interval<int> > formulas = formulaIntervals(); // foreach(const Interval<int>& interval, formulas) { // writer->writeStartElement("formula"); // writer->writeAttribute("start_row", QString::number(interval.start())); // writer->writeAttribute("end_row", QString::number(interval.end())); // writer->writeCharacters(formula(interval.start())); // writer->writeEndElement(); // } int i; switch(columnMode()) { case AbstractColumn::Numeric: { const char* data = reinterpret_cast<const char*>( static_cast< QVector<double>* >(m_column_private->dataPointer())->constData()); int size = m_column_private->rowCount()*sizeof(double); writer->writeCharacters(QByteArray::fromRawData(data,size).toBase64()); break; } case AbstractColumn::Text: for(i=0; i<rowCount(); ++i) { writer->writeStartElement("row"); writer->writeAttribute("index", QString::number(i)); writer->writeCharacters(textAt(i)); writer->writeEndElement(); } break; case AbstractColumn::DateTime: case AbstractColumn::Month: case AbstractColumn::Day: for(i=0; i<rowCount(); ++i) { writer->writeStartElement("row"); writer->writeAttribute("index", QString::number(i)); writer->writeCharacters(dateTimeAt(i).toString("yyyy-dd-MM hh:mm:ss:zzz")); writer->writeEndElement(); } break; } writer->writeEndElement(); // "column" }