Move search code to seperate function.
This commit is contained in:
@@ -536,6 +536,43 @@ void ProjectExplorer::DeselectAll()
|
||||
CurrentView()->selectionModel()->clearSelection();
|
||||
}
|
||||
|
||||
QList<Node*> ProjectExplorer::GetItemNodes(Item* item, Item::Type type)
|
||||
{
|
||||
// Output list list
|
||||
QList<Node*> nodes;
|
||||
|
||||
// Get all sequences.
|
||||
QList<ItemPtr> sequences = model_.project()->get_items_of_type(Item::kSequence);
|
||||
// Get item pointer.
|
||||
ItemPtr item_ptr = item->get_shared_ptr();
|
||||
|
||||
if (type == Item::kFootage) {
|
||||
// If no sequences exist we don't need to do anything clever here
|
||||
if (!sequences.isEmpty()) {
|
||||
// Footage can contain multiple streams, all of which need to be dealt with
|
||||
foreach (StreamPtr stream, static_cast<Footage*>(item_ptr.get())->streams()) {
|
||||
// Check each sequence to see if it contains the footage in question
|
||||
foreach (ItemPtr seq, sequences) {
|
||||
Sequence* s = static_cast<Sequence*>(seq.get());
|
||||
|
||||
// Loop through nodes to find our Footage node
|
||||
foreach (Node* node, s->nodes()) {
|
||||
// Check if node is of the right type
|
||||
if (node->IsMedia() && static_cast<MediaInput*>(node)->type() == stream.get()->type() ||
|
||||
static_cast<MediaInput*>(node)->type() == Stream::kImage) {
|
||||
// Check the streams are the same
|
||||
if (static_cast<MediaInput*>(node)->footage() == stream) {
|
||||
nodes.append(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
void ProjectExplorer::DeleteSelected()
|
||||
{
|
||||
QList<Item*> selected = SelectedItems();
|
||||
@@ -558,53 +595,44 @@ void ProjectExplorer::DeleteSelected()
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a footage item, clean up if necessary
|
||||
if (item_ptr->type() == Item::kFootage) {
|
||||
// Get all sequences
|
||||
QList<ItemPtr> sequences = model_.project()->get_items_of_type(Item::kSequence);
|
||||
|
||||
// Check if nodes exists
|
||||
QList<Node*> nodes = GetItemNodes(item, Item::kFootage);
|
||||
if (!nodes.isEmpty()){
|
||||
// Loop through Footage nodes
|
||||
foreach (Node* node, nodes) {
|
||||
|
||||
// If no sequences exist we don't need to do anything clever here
|
||||
if (!sequences.isEmpty()) {
|
||||
// Footage can contain multiple streams, all of which need to be dealt with
|
||||
foreach (StreamPtr stream, static_cast<Footage*>(item_ptr.get())->streams()) {
|
||||
|
||||
// Check each sequence to see if it contains the footage in question
|
||||
// Loop through sequences
|
||||
QList<ItemPtr> sequences = model_.project()->get_items_of_type(Item::kSequence);
|
||||
foreach (ItemPtr seq, sequences) {
|
||||
|
||||
Sequence* s = static_cast<Sequence*>(seq.get());
|
||||
|
||||
// Loop through nodes to find our Footage node
|
||||
foreach (Node* node, s->nodes()) {
|
||||
// Check all nodes to see if they're linked
|
||||
foreach (Node* check_node, s->nodes()) {
|
||||
// Skip itself
|
||||
if (nodes.contains(check_node)) {
|
||||
continue;
|
||||
}
|
||||
if (check_node->GetImmediateDependencies().contains(node)) {
|
||||
QList<NodeInput*> inputs = check_node->GetInputsIncludingArrays();
|
||||
|
||||
// Check if node is of the right type
|
||||
if (node->IsMedia() && static_cast<MediaInput*>(node)->type() == stream.get()->type()) {
|
||||
// Check the streams are the same
|
||||
if (static_cast<MediaInput*>(node)->footage() == stream) {
|
||||
// Loop through nodes and set any that point to the Footage node to null
|
||||
foreach (Node* check_node, s->nodes()) {
|
||||
// Skip itself
|
||||
if (check_node == node) {
|
||||
continue;
|
||||
}
|
||||
if (check_node->GetImmediateDependencies().contains(node)) {
|
||||
QList<NodeInput*> inputs = check_node->GetInputsIncludingArrays();
|
||||
foreach (NodeInput* input, inputs) {
|
||||
foreach (NodeEdgePtr edge, input->edges()) {
|
||||
Node* connected = edge->output()->parentNode();
|
||||
|
||||
foreach (NodeInput* input, inputs) {
|
||||
foreach (NodeEdgePtr edge, input->edges()) {
|
||||
Node* connected = edge->output()->parentNode();
|
||||
|
||||
if (connected == node) {
|
||||
input->DisconnectEdge(edge);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (connected == node) {
|
||||
input->DisconnectEdge(edge);
|
||||
}
|
||||
}
|
||||
static_cast<MediaInput*>(node)->SetFootage(nullptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set footage to be null
|
||||
static_cast<MediaInput*>(node)->SetFootage(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user