const MarkInCompressedFile & MergeTreeReader::Stream::getMark(size_t index) { if (!marks) loadMarks(); return (*marks)[index]; }
void EditorTabWidget::slotMarkChanged() { //I get sick looking at this code... //terminating: prevent from crash if(m_terminating) return; QValueList<Document_t>::iterator it = m_docList.at(currentPageIndex()); QPtrList<KTextEditor::Mark> currentMarks = documentMarkIf((*it).path)->marks(); QValueList<KTextEditor::Mark> & oldMarks = (*it).marks; KTextEditor::Mark *cur; QValueList<KTextEditor::Mark>::iterator old; //closeGuard: prevent from emit signals to remove bp marks(we want them persistent) //m_markGuard: prevent from processing marks twice if(m_closeGuard || m_markGuard) goto end; if(oldMarks.count() == currentMarks.count()) { //--2+ marks on the same line | mark changed position KTextEditor::Mark mark; for(cur = currentMarks.first(), old = oldMarks.begin(); cur; cur = currentMarks.next(), ++old) { if((cur->line == (*old).line) && (cur->type != (*old).type)) { //--2+ marks on the same line mark.line = cur->line; if(cur->type > (*old).type) { mark.type = cur->type - (*old).type; //add dispatchMark(mark, true); } else { //remove mark.type = (*old).type - cur->type; dispatchMark(mark, false); } //break; } else if((*old).line != cur->line) { //mark changed position //remove old dispatchMark((*old), false); //add new dispatchMark(*cur, true); } } } else if(oldMarks.count() > currentMarks.count()) { //a mark was removed if(currentMarks.count() == 0) { dispatchMark(*(oldMarks.begin()), false); } else { bool found; for(old = oldMarks.begin(); old != oldMarks.end(); ++old) { found = false; for(cur = currentMarks.first(); cur; cur = currentMarks.next()) { if(((*old).line == cur->line) && ((*old).type |= cur->type)) { found = true; break; } } if(found == false) { dispatchMark(*old, false); break; } } } } else { //a mark was added if(oldMarks.count() == 0) { dispatchMark(*(currentMarks.first()), true); } else { bool found; for(cur = currentMarks.first(); cur; cur = currentMarks.next()) { found = false; for(old = oldMarks.begin(); old != oldMarks.end(); ++old) { if(((*old).line == cur->line) && ((*old).type |= cur->type)) { found = true; break; } } if(found == false) { dispatchMark(*cur, true); break; } } } } end: loadMarks((*it), (*it).view->document()); }