Move search code to seperate function.
This commit is contained in:
@@ -536,6 +536,43 @@ void ProjectExplorer::DeselectAll()
|
|||||||
CurrentView()->selectionModel()->clearSelection();
|
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()
|
void ProjectExplorer::DeleteSelected()
|
||||||
{
|
{
|
||||||
QList<Item*> selected = SelectedItems();
|
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) {
|
if (item_ptr->type() == Item::kFootage) {
|
||||||
// Get all sequences
|
|
||||||
QList<ItemPtr> sequences = model_.project()->get_items_of_type(Item::kSequence);
|
|
||||||
|
|
||||||
// If no sequences exist we don't need to do anything clever here
|
// Check if nodes exists
|
||||||
if (!sequences.isEmpty()) {
|
QList<Node*> nodes = GetItemNodes(item, Item::kFootage);
|
||||||
// Footage can contain multiple streams, all of which need to be dealt with
|
if (!nodes.isEmpty()){
|
||||||
foreach (StreamPtr stream, static_cast<Footage*>(item_ptr.get())->streams()) {
|
// Loop through Footage nodes
|
||||||
|
foreach (Node* node, nodes) {
|
||||||
|
|
||||||
// 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) {
|
foreach (ItemPtr seq, sequences) {
|
||||||
|
|
||||||
Sequence* s = static_cast<Sequence*>(seq.get());
|
Sequence* s = static_cast<Sequence*>(seq.get());
|
||||||
|
|
||||||
// Loop through nodes to find our Footage node
|
// Check all nodes to see if they're linked
|
||||||
foreach (Node* node, s->nodes()) {
|
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
|
foreach (NodeInput* input, inputs) {
|
||||||
if (node->IsMedia() && static_cast<MediaInput*>(node)->type() == stream.get()->type()) {
|
foreach (NodeEdgePtr edge, input->edges()) {
|
||||||
// Check the streams are the same
|
Node* connected = edge->output()->parentNode();
|
||||||
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) {
|
if (connected == node) {
|
||||||
foreach (NodeEdgePtr edge, input->edges()) {
|
input->DisconnectEdge(edge);
|
||||||
Node* connected = edge->output()->parentNode();
|
|
||||||
|
|
||||||
if (connected == node) {
|
|
||||||
input->DisconnectEdge(edge);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static_cast<MediaInput*>(node)->SetFootage(nullptr);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set footage to be null
|
||||||
|
static_cast<MediaInput*>(node)->SetFootage(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,12 @@ public:
|
|||||||
|
|
||||||
void DeleteSelected();
|
void DeleteSelected();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if an item is in use anywhere and return any relevant input nodes
|
||||||
|
* kFootage has two streams that need to be handled
|
||||||
|
*/
|
||||||
|
QList<Node*> GetItemNodes(Item* item, Item::Type type);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void set_view_type(ProjectToolbar::ViewType type);
|
void set_view_type(ProjectToolbar::ViewType type);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user