void KDocumentTextBuffer::localTextInserted( KTextEditor::Document *document, const KTextEditor::Range &range ) { if ( m_aboutToClose ) return; emit localChangedText(range, user(), false); Q_UNUSED(document) textOpPerformed(); if( m_user.isNull() ) { kDebug() << "Could not insert text: No local user set."; return; } unsigned int offset = cursorToOffset_kte(range.start()); kDebug() << "local text inserted" << kDocument() << "( range" << range << ")" << m_user << "offset:" << offset; QInfinity::TextChunk chunk(encoding()); QString text = kDocument()->text(range); #ifdef ENABLE_TAB_HACK if ( text.contains('\t') ) { text = text.replace('\t', " "); kDocument()->blockSignals(true); kDocument()->replaceText(range, text); kDocument()->blockSignals(false); } #endif Q_ASSERT(encoder()); if ( text.isEmpty() ) { kDebug() << "Skipping empty insert."; return; } QByteArray encodedText = codec()->fromUnicode( text ); if ( encodedText.size() == 0 ) { kDebug() << "Got empty encoded text from non empty string " "Skipping insertion"; } else { chunk.insertText( 0, encodedText, countUnicodeCharacters(text), m_user->id() ); blockRemoteInsert = true; kDebug() << "inserting chunk of size" << chunk.length() << "into local buffer" << kDocument()->url(); insertChunk( offset, chunk, m_user ); kDebug() << "done inserting chunk"; checkConsistency(); } }
/** \brief Adds the chunk to the trip */ void cwTrip::addChunk(cwSurveyChunk* chunk) { insertChunk(numberOfChunks(), chunk); }