bool Annotate::getNextSection(SCRef d, int& idx, QString& sec, SCRef target) { if (idx >= d.length()) return false; int newIdx = d.indexOf(target, idx); if (newIdx == -1) // last section, take all newIdx = d.length() - 1; sec = d.mid(idx, newIdx - idx + 1); idx = newIdx + 1; return true; }