| 2179 | // I think the actors themselves need to support a clone atom.. |
| 2180 | |
| 2181 | void SessionActor::duplicate_container( |
| 2182 | caf::typed_response_promise<UuidVector> rp, |
| 2183 | const utility::UuidTree<utility::PlaylistItem> &tree, |
| 2184 | caf::actor source_session, |
| 2185 | const utility::Uuid &uuid_before, |
| 2186 | const bool into, |
| 2187 | const bool rename, |
| 2188 | const bool kill_source) { |
| 2189 | |
| 2190 | // find all actor children.. (Timeline/SUBSET/CONTACTSHEET) |
| 2191 | // quick clone of divider.. |
| 2192 | |
| 2193 | // clone structure |
| 2194 | PlaylistTree new_tree(tree); |
| 2195 | |
| 2196 | // regenerate uuids.. |
| 2197 | new_tree.reset_uuid(true); |
| 2198 | |
| 2199 | duplicate_tree(new_tree, source_session, rename); |
| 2200 | |
| 2201 | std::function<void(const PlaylistTree &, std::vector<Uuid> &)> flatten_tree; |
| 2202 | flatten_tree = [&flatten_tree](const PlaylistTree &tree, std::vector<Uuid> &rt) { |
| 2203 | rt.push_back(tree.uuid()); |
| 2204 | for (auto i : tree.children_ref()) { |
| 2205 | flatten_tree(i, rt); |
| 2206 | } |
| 2207 | }; |
| 2208 | |
| 2209 | std::vector<Uuid> ordered_uuids; |
| 2210 | |
| 2211 | // If we clone a session we need to reparent the children of the tree. |
| 2212 | // As they sit under the session item. |
| 2213 | if (new_tree.value().type() == "Session" or new_tree.value().type() == "") { |
| 2214 | // reparent.. |
| 2215 | for (auto &i : new_tree.children_) { |
| 2216 | flatten_tree(i, ordered_uuids); |
| 2217 | base_.insert_container(i, uuid_before, into); |
| 2218 | } |
| 2219 | |
| 2220 | } else { |
| 2221 | flatten_tree(new_tree, ordered_uuids); |
| 2222 | base_.insert_container(new_tree, uuid_before, into); |
| 2223 | } |
| 2224 | |
| 2225 | base_.send_changed(); |
| 2226 | |
| 2227 | if (kill_source) |
| 2228 | send_exit(source_session, caf::exit_reason::user_shutdown); |
| 2229 | |
| 2230 | rp.deliver(ordered_uuids); |
| 2231 | } |
| 2232 | |
| 2233 | // session actors container groups/dividers and playlists.. |
| 2234 | void SessionActor::duplicate_tree( |
nothing calls this directly
no test coverage detected