MCPcopy Create free account
hub / github.com/KDE/okular / EditTextCommand

Method EditTextCommand

core/documentcommands.cpp:326–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326EditTextCommand::EditTextCommand(const QString &newContents, int newCursorPos, const QString &prevContents, int prevCursorPos, int prevAnchorPos)
327 : m_newContents(newContents)
328 , m_newCursorPos(newCursorPos)
329 , m_prevContents(prevContents)
330 , m_prevCursorPos(prevCursorPos)
331 , m_prevAnchorPos(prevAnchorPos)
332{
333 setText(i18nc("Generic text edit command", "edit text"));
334
335 //// Determine edit type
336 // If There was a selection then edit was not a simple single character backspace, delete, or insert
337 if (m_prevCursorPos != m_prevAnchorPos) {
338 qCDebug(OkularCoreDebug) << "OtherEdit, selection";
339 m_editType = OtherEdit;
340 } else if (newContentsRightOfCursor() == oldContentsRightOfCursor() && newContentsLeftOfCursor() == oldContentsLeftOfCursor().left(oldContentsLeftOfCursor().length() - 1) &&
341 QStringView {oldContentsLeftOfCursor()}.right(1) != QLatin1Char('\n')) {
342 qCDebug(OkularCoreDebug) << "CharBackspace";
343 m_editType = CharBackspace;
344 } else if (newContentsLeftOfCursor() == oldContentsLeftOfCursor() && newContentsRightOfCursor() == oldContentsRightOfCursor().right(oldContentsRightOfCursor().length() - 1) &&
345 QStringView {oldContentsRightOfCursor()}.left(1) != QLatin1Char('\n')) {
346 qCDebug(OkularCoreDebug) << "CharDelete";
347 m_editType = CharDelete;
348 } else if (newContentsRightOfCursor() == oldContentsRightOfCursor() && newContentsLeftOfCursor().left(newContentsLeftOfCursor().length() - 1) == oldContentsLeftOfCursor() &&
349 QStringView {newContentsLeftOfCursor()}.right(1) != QLatin1Char('\n')) {
350 qCDebug(OkularCoreDebug) << "CharInsert";
351 m_editType = CharInsert;
352 } else {
353 qCDebug(OkularCoreDebug) << "OtherEdit";
354 m_editType = OtherEdit;
355 }
356}
357
358bool EditTextCommand::mergeWith(const QUndoCommand *uc)
359{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected