MCPcopy Create free account
hub / github.com/Palm1r/QodeAssist / dimContextLines

Method dimContextLines

widgets/RefactorWidget.cpp:344–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344void RefactorWidget::dimContextLines(const QString &contextBefore, const QString &contextAfter)
345{
346 QTextCharFormat dimFormat;
347 dimFormat.setForeground(Utils::creatorColor(Utils::Theme::TextColorDisabled));
348
349 auto dimLines = [&](QTextDocument *doc, int lineCount, bool fromStart) {
350 QTextCursor cursor(doc);
351 if (!fromStart) {
352 cursor.movePosition(QTextCursor::End);
353 }
354
355 for (int i = 0; i < lineCount; ++i) {
356 cursor.movePosition(QTextCursor::StartOfBlock);
357 cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
358 cursor.setCharFormat(dimFormat);
359
360 if (fromStart) {
361 if (!cursor.block().isValid() || !cursor.movePosition(QTextCursor::NextBlock)) {
362 break;
363 }
364 } else {
365 if (!cursor.movePosition(QTextCursor::PreviousBlock)) {
366 break;
367 }
368 }
369 }
370 };
371
372 if (!contextBefore.isEmpty()) {
373 int lines = contextBefore.count('\n') + (contextBefore.endsWith('\n') ? 0 : 1);
374 dimLines(m_leftDocument->document(), lines, true);
375 dimLines(m_rightDocument->document(), lines, true);
376 }
377
378 if (!contextAfter.isEmpty()) {
379 int lines = contextAfter.count('\n') + (contextAfter.endsWith('\n') ? 0 : 1);
380 dimLines(m_leftDocument->document(), lines, false);
381 dimLines(m_rightDocument->document(), lines, false);
382 }
383}
384
385QString RefactorWidget::getRefactoredText() const
386{

Callers

nothing calls this directly

Calls 3

documentMethod · 0.80
isValidMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected