MCPcopy Create free account
hub / github.com/KDAB/GammaRay / toggleFold

Method toggleFold

ui/codeeditor/codeeditor.cpp:296–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296void CodeEditor::toggleFold(const QTextBlock &startBlock)
297{
298#ifdef HAVE_SYNTAX_HIGHLIGHTING
299 // we also want to fold the last line of the region, therefore the ".next()"
300 const auto endBlock = m_highlighter->findFoldingRegionEnd(startBlock).next();
301
302 if (isFolded(startBlock)) {
303 // unfold
304 auto block = startBlock.next();
305 while (block.isValid() && !block.isVisible()) {
306 block.setVisible(true);
307 block.setLineCount(block.layout()->lineCount());
308 block = block.next();
309 }
310
311 } else {
312 // fold
313 auto block = startBlock.next();
314 while (block.isValid() && block != endBlock) {
315 block.setVisible(false);
316 block.setLineCount(0);
317 block = block.next();
318 }
319 }
320
321 // redraw document
322 document()->markContentsDirty(startBlock.position(), endBlock.position() - startBlock.position() + 1);
323 // update scrollbars
324 emit document()->documentLayout()->documentSizeChanged(document()->documentLayout()->documentSize());
325#else
326 Q_UNUSED(startBlock);
327#endif
328}

Callers 1

mouseReleaseEventMethod · 0.80

Calls 3

isValidMethod · 0.45
isVisibleMethod · 0.45
layoutMethod · 0.45

Tested by

no test coverage detected