/** * Roll an unrolled algorithm history item and remove its children from the *view. * * This removes each of the child algorithm histories (if any) and marks * the parent as being "rolled up". Note that this will recursively "roll up" *any child * history objects that are also unrolled. This method does nothing if * the history object has no children. * * @param it :: iterator to the list of history item objects at the positon to *roll */ void HistoryView::roll(std::vector<HistoryItem>::iterator &it) { // the number of records after this position const size_t numChildren = it->numberOfChildren(); if (it->isUnrolled() && numChildren > 0) { // mark this record as not being ignored by the script builder it->unrolled(false); this->rollChildren(it); // Then just remove the children from the list ++it; it = m_historyItems.erase(it, it + numChildren); } else ++it; }
/** * Unroll an algorithm history to export its child algorithms. * * This places each of the child algorithm histories into the * HistoryView object. The parent is retained as a marker so we can * "roll" the history back up if we want. This method does nothing if * the history object has no children * * @param it :: iterator to the list of history item objects at the position to *unroll */ void HistoryView::unroll(std::vector<HistoryItem>::iterator &it) { const auto history = it->getAlgorithmHistory(); const auto childHistories = history->getChildHistories(); if (!it->isUnrolled() && !childHistories.empty()) { // mark this record as being ignored by the script builder it->unrolled(true); // insert each of the records, in order, at this position std::vector<HistoryItem> tmpHistory(childHistories.cbegin(), childHistories.cend()); // since we are using a std::vector, do all insertions at the same time. ++it; // move iterator forward to insertion position it = m_historyItems.insert(it, tmpHistory.begin(), tmpHistory.end()); } else ++it; }