Changeset View
Changeset View
Standalone View
Standalone View
src/buffer/katetextbuffer.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 87 | { | |||
---|---|---|---|---|---|
110 | QSet<TextCursor *> copyCursors = m_invalidCursors; | 110 | QSet<TextCursor *> copyCursors = m_invalidCursors; | ||
111 | qDeleteAll(copyCursors); | 111 | qDeleteAll(copyCursors); | ||
112 | Q_ASSERT(m_invalidCursors.empty()); | 112 | Q_ASSERT(m_invalidCursors.empty()); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | void TextBuffer::invalidateRanges() | 115 | void TextBuffer::invalidateRanges() | ||
116 | { | 116 | { | ||
117 | // invalidate all ranges, work on copy, they might delete themself... | 117 | // invalidate all ranges, work on copy, they might delete themself... | ||
118 | QSet<TextRange *> copyRanges = m_ranges; | 118 | const QSet<TextRange *> copyRanges = m_ranges; | ||
119 | foreach (TextRange *range, copyRanges) { | 119 | for (TextRange *range : copyRanges) { | ||
120 | range->setRange(KTextEditor::Cursor::invalid(), KTextEditor::Cursor::invalid()); | 120 | range->setRange(KTextEditor::Cursor::invalid(), KTextEditor::Cursor::invalid()); | ||
121 | } | 121 | } | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | void TextBuffer::clear() | 124 | void TextBuffer::clear() | ||
125 | { | 125 | { | ||
126 | // not allowed during editing | 126 | // not allowed during editing | ||
127 | Q_ASSERT(m_editingTransactions == 0); | 127 | Q_ASSERT(m_editingTransactions == 0); | ||
▲ Show 20 Lines • Show All 871 Lines • ▼ Show 20 Line(s) | 995 | { | |||
999 | if (!m_document) { | 999 | if (!m_document) { | ||
1000 | return; | 1000 | return; | ||
1001 | } | 1001 | } | ||
1002 | 1002 | | |||
1003 | /** | 1003 | /** | ||
1004 | * update all views, this IS ugly and could be a signal, but I profiled and a signal is TOO slow, really | 1004 | * update all views, this IS ugly and could be a signal, but I profiled and a signal is TOO slow, really | ||
1005 | * just create 20k ranges in a go and you wait seconds on a decent machine | 1005 | * just create 20k ranges in a go and you wait seconds on a decent machine | ||
1006 | */ | 1006 | */ | ||
1007 | const QList<KTextEditor::View *> &views = m_document->views(); | 1007 | const QList<KTextEditor::View *> views = m_document->views(); | ||
1008 | foreach (KTextEditor::View *curView, views) { | 1008 | for (KTextEditor::View *curView : views) { | ||
1009 | // filter wrong views | 1009 | // filter wrong views | ||
1010 | if (view && view != curView) { | 1010 | if (view && view != curView) { | ||
1011 | continue; | 1011 | continue; | ||
1012 | } | 1012 | } | ||
1013 | 1013 | | |||
1014 | // notify view, it is really a kate view | 1014 | // notify view, it is really a kate view | ||
1015 | static_cast<KTextEditor::ViewPrivate *>(curView)->notifyAboutRangeChange(startLine, endLine, rangeWithAttribute); | 1015 | static_cast<KTextEditor::ViewPrivate *>(curView)->notifyAboutRangeChange(startLine, endLine, rangeWithAttribute); | ||
1016 | } | 1016 | } | ||
1017 | } | 1017 | } | ||
1018 | 1018 | | |||
1019 | void TextBuffer::markModifiedLinesAsSaved() | 1019 | void TextBuffer::markModifiedLinesAsSaved() | ||
1020 | { | 1020 | { | ||
1021 | foreach (TextBlock *block, m_blocks) { | 1021 | foreach (TextBlock *block, m_blocks) { | ||
1022 | block->markModifiedLinesAsSaved(); | 1022 | block->markModifiedLinesAsSaved(); | ||
1023 | } | 1023 | } | ||
1024 | } | 1024 | } | ||
1025 | 1025 | | |||
1026 | QList<TextRange *> TextBuffer::rangesForLine(int line, KTextEditor::View *view, bool rangesWithAttributeOnly) const | 1026 | QList<TextRange *> TextBuffer::rangesForLine(int line, KTextEditor::View *view, bool rangesWithAttributeOnly) const | ||
1027 | { | 1027 | { | ||
1028 | // get block, this will assert on invalid line | 1028 | // get block, this will assert on invalid line | ||
1029 | const int blockIndex = blockForLine(line); | 1029 | const int blockIndex = blockForLine(line); | ||
1030 | 1030 | | |||
1031 | // get the ranges of the right block | 1031 | // get the ranges of the right block | ||
1032 | QList<TextRange *> rightRanges; | 1032 | QList<TextRange *> rightRanges; | ||
1033 | foreach (const QSet<TextRange *> &ranges, m_blocks.at(blockIndex)->rangesForLine(line)) { | 1033 | const auto blockRanges = m_blocks.at(blockIndex)->rangesForLine(line); | ||
1034 | foreach (TextRange *const range, ranges) { | 1034 | for (const QSet<TextRange*> &ranges : blockRanges) { | ||
1035 | for (TextRange *const range : ranges) { | ||||
1035 | /** | 1036 | /** | ||
1036 | * we want only ranges with attributes, but this one has none | 1037 | * we want only ranges with attributes, but this one has none | ||
1037 | */ | 1038 | */ | ||
1038 | if (rangesWithAttributeOnly && !range->hasAttribute()) { | 1039 | if (rangesWithAttributeOnly && !range->hasAttribute()) { | ||
1039 | continue; | 1040 | continue; | ||
1040 | } | 1041 | } | ||
1041 | 1042 | | |||
1042 | /** | 1043 | /** | ||
Show All 27 Lines |