switched many QLists for QVectors
Minor optimization
This commit is contained in:
@@ -115,7 +115,7 @@ void NodeView::DeleteSelected()
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
{
|
||||
QList<NodeEdge*> selected_edges = scene_.GetSelectedEdges();
|
||||
QVector<NodeEdge*> selected_edges = scene_.GetSelectedEdges();
|
||||
|
||||
foreach (NodeEdge* edge, selected_edges) {
|
||||
new NodeEdgeRemoveCommand(edge->output(), edge->input(), command);
|
||||
@@ -124,7 +124,7 @@ void NodeView::DeleteSelected()
|
||||
}
|
||||
|
||||
{
|
||||
QList<Node*> selected_nodes = scene_.GetSelectedNodes();
|
||||
QVector<Node*> selected_nodes = scene_.GetSelectedNodes();
|
||||
|
||||
// Ensure no nodes are "undeletable"
|
||||
for (int i=0;i<selected_nodes.size();i++) {
|
||||
@@ -166,7 +166,7 @@ void NodeView::DeselectAll()
|
||||
SceneSelectionChangedSlot();
|
||||
}
|
||||
|
||||
void NodeView::Select(const QList<Node *> &nodes)
|
||||
void NodeView::Select(const QVector<Node *> &nodes)
|
||||
{
|
||||
if (!graph_) {
|
||||
return;
|
||||
@@ -188,7 +188,7 @@ void NodeView::Select(const QList<Node *> &nodes)
|
||||
SceneSelectionChangedSlot();
|
||||
}
|
||||
|
||||
void NodeView::SelectWithDependencies(QList<Node *> nodes)
|
||||
void NodeView::SelectWithDependencies(QVector<Node *> nodes)
|
||||
{
|
||||
if (!graph_) {
|
||||
return;
|
||||
@@ -202,7 +202,7 @@ void NodeView::SelectWithDependencies(QList<Node *> nodes)
|
||||
Select(nodes);
|
||||
}
|
||||
|
||||
void NodeView::SelectBlocks(const QList<Block *> &blocks)
|
||||
void NodeView::SelectBlocks(const QVector<Block *> &blocks)
|
||||
{
|
||||
if (!graph_) {
|
||||
return;
|
||||
@@ -213,7 +213,7 @@ void NodeView::SelectBlocks(const QList<Block *> &blocks)
|
||||
QueueSelectBlocksInternal();
|
||||
}
|
||||
|
||||
void NodeView::DeselectBlocks(const QList<Block *> &blocks)
|
||||
void NodeView::DeselectBlocks(const QVector<Block *> &blocks)
|
||||
{
|
||||
if (!graph_) {
|
||||
return;
|
||||
@@ -240,7 +240,7 @@ void NodeView::CopySelected(bool cut)
|
||||
return;
|
||||
}
|
||||
|
||||
QList<Node*> selected = scene_.GetSelectedNodes();
|
||||
QVector<Node*> selected = scene_.GetSelectedNodes();
|
||||
|
||||
if (selected.isEmpty()) {
|
||||
return;
|
||||
@@ -261,7 +261,7 @@ void NodeView::Paste()
|
||||
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
QList<Node*> pasted_nodes = PasteNodesFromClipboard(static_cast<Sequence*>(graph_), command);
|
||||
QVector<Node*> pasted_nodes = PasteNodesFromClipboard(static_cast<Sequence*>(graph_), command);
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
|
||||
@@ -280,7 +280,7 @@ void NodeView::Duplicate()
|
||||
return;
|
||||
}
|
||||
|
||||
QList<Node*> selected = scene_.GetSelectedNodes();
|
||||
QVector<Node*> selected = scene_.GetSelectedNodes();
|
||||
|
||||
if (selected.isEmpty()) {
|
||||
return;
|
||||
@@ -488,10 +488,10 @@ void NodeView::wheelEvent(QWheelEvent *event)
|
||||
|
||||
void NodeView::SceneSelectionChangedSlot()
|
||||
{
|
||||
QList<Node*> current_selection = scene_.GetSelectedNodes();
|
||||
QVector<Node*> current_selection = scene_.GetSelectedNodes();
|
||||
|
||||
QList<Node*> selected;
|
||||
QList<Node*> deselected;
|
||||
QVector<Node*> selected;
|
||||
QVector<Node*> deselected;
|
||||
|
||||
// Determine which nodes are newly selected
|
||||
if (selected_nodes_.isEmpty()) {
|
||||
@@ -540,7 +540,7 @@ void NodeView::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
m.addSeparator();
|
||||
|
||||
QList<NodeViewItem*> selected = scene_.GetSelectedItems();
|
||||
QVector<NodeViewItem*> selected = scene_.GetSelectedItems();
|
||||
|
||||
if (itemAt(pos) && !selected.isEmpty()) {
|
||||
|
||||
@@ -636,7 +636,7 @@ void NodeView::ContextMenuSetDirection(QAction *action)
|
||||
|
||||
void NodeView::AutoPositionDescendents()
|
||||
{
|
||||
QList<Node*> selected = scene_.GetSelectedNodes();
|
||||
QVector<Node*> selected = scene_.GetSelectedNodes();
|
||||
|
||||
foreach (Node* n, selected) {
|
||||
scene_.ReorganizeFrom(n);
|
||||
@@ -665,18 +665,18 @@ void NodeView::ContextMenuFilterChanged(QAction *action)
|
||||
}
|
||||
}
|
||||
|
||||
void NodeView::AttachNodesToCursor(const QList<Node *> &nodes)
|
||||
void NodeView::AttachNodesToCursor(const QVector<Node *> &nodes)
|
||||
{
|
||||
QList<NodeViewItem*> items;
|
||||
QVector<NodeViewItem*> items(nodes.size());
|
||||
|
||||
foreach (Node* p, nodes) {
|
||||
items.append(scene_.NodeToUIObject(p));
|
||||
for (int i=0; i<nodes.size(); i++) {
|
||||
items[i] = scene_.NodeToUIObject(nodes.at(i));
|
||||
}
|
||||
|
||||
AttachItemsToCursor(items);
|
||||
}
|
||||
|
||||
void NodeView::AttachItemsToCursor(const QList<NodeViewItem*>& items)
|
||||
void NodeView::AttachItemsToCursor(const QVector<NodeViewItem*>& items)
|
||||
{
|
||||
DetachItemsFromCursor();
|
||||
|
||||
@@ -731,7 +731,7 @@ void NodeView::UpdateBlockFilter()
|
||||
bool first = true;
|
||||
QPointF last_bottom_right;
|
||||
|
||||
QList<Node*> currently_visible;
|
||||
QVector<Node*> currently_visible;
|
||||
|
||||
foreach (Block* b, selected_blocks_) {
|
||||
// Auto-position this node's dependencies
|
||||
@@ -741,7 +741,7 @@ void NodeView::UpdateBlockFilter()
|
||||
QPointF node_pos = b->GetPosition();
|
||||
QRectF anchor(node_pos, node_pos);
|
||||
|
||||
QList<Node*> deps = b->GetDependencies();
|
||||
QVector<Node*> deps = b->GetDependencies();
|
||||
|
||||
foreach (Node* d, deps) {
|
||||
QPointF dep_pos = d->GetPosition();
|
||||
@@ -779,8 +779,7 @@ void NodeView::UpdateBlockFilter()
|
||||
|
||||
// ...then add its associations
|
||||
deps.append(temporary_association_map_[b]);
|
||||
QHash<Node*, QList<Block*> >::const_iterator i;
|
||||
for (i=association_map_.begin(); i!=association_map_.end(); i++) {
|
||||
for (auto i=association_map_.begin(); i!=association_map_.end(); i++) {
|
||||
if (i.value().contains(b)) {
|
||||
deps.append(i.key());
|
||||
}
|
||||
@@ -835,7 +834,7 @@ void NodeView::SelectBlocksInternal()
|
||||
UpdateBlockFilter();
|
||||
}
|
||||
|
||||
QList<Node*> nodes;
|
||||
QVector<Node*> nodes;
|
||||
nodes.reserve(selected_blocks_.size());
|
||||
|
||||
foreach (Block* b, selected_blocks_) {
|
||||
@@ -888,7 +887,7 @@ void NodeView::GraphEdgeAdded(NodeEdgePtr edge)
|
||||
Node* input_node = edge->input()->parentNode();
|
||||
|
||||
if (input_node->OutputsTo(static_cast<Sequence*>(graph_)->viewer_output(), true)) {
|
||||
QHash<Node*, QList<Block*> >::const_iterator i = association_map_.begin();
|
||||
auto i = association_map_.begin();
|
||||
|
||||
while (i != association_map_.end()) {
|
||||
if (input_node->InputsFrom(i.key(), true)) {
|
||||
@@ -917,14 +916,14 @@ void NodeView::GraphEdgeRemoved(NodeEdgePtr edge)
|
||||
}
|
||||
}
|
||||
|
||||
QList<Node*> disconnected_nodes;
|
||||
QVector<Node*> disconnected_nodes;
|
||||
disconnected_nodes.append(output_node);
|
||||
disconnected_nodes.append(output_node->GetDependencies());
|
||||
|
||||
if (output_node->OutputsTo(static_cast<Sequence*>(graph_)->viewer_output(), true)) {
|
||||
// Check if this disconnected node still has a path to the viewer somewhere else
|
||||
foreach (Block* b, selected_blocks_) {
|
||||
QList<Node*>& temp_assocs = temporary_association_map_[b];
|
||||
QVector<Node*>& temp_assocs = temporary_association_map_[b];
|
||||
|
||||
temp_assocs.append(disconnected_nodes);
|
||||
}
|
||||
|
||||
@@ -58,22 +58,22 @@ public:
|
||||
void SelectAll();
|
||||
void DeselectAll();
|
||||
|
||||
void Select(const QList<Node*>& nodes);
|
||||
void SelectWithDependencies(QList<Node *> nodes);
|
||||
void Select(const QVector<Node*>& nodes);
|
||||
void SelectWithDependencies(QVector<Node *> nodes);
|
||||
|
||||
void CopySelected(bool cut);
|
||||
void Paste();
|
||||
|
||||
void Duplicate();
|
||||
|
||||
void SelectBlocks(const QList<Block*>& blocks);
|
||||
void SelectBlocks(const QVector<Block*>& blocks);
|
||||
|
||||
void DeselectBlocks(const QList<Block*>& blocks);
|
||||
void DeselectBlocks(const QVector<Block*>& blocks);
|
||||
|
||||
signals:
|
||||
void NodesSelected(const QList<Node*>& nodes);
|
||||
void NodesSelected(const QVector<Node*>& nodes);
|
||||
|
||||
void NodesDeselected(const QList<Node*>& nodes);
|
||||
void NodesDeselected(const QVector<Node*>& nodes);
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
@@ -85,9 +85,9 @@ protected:
|
||||
virtual void wheelEvent(QWheelEvent* event) override;
|
||||
|
||||
private:
|
||||
void AttachNodesToCursor(const QList<Node*>& nodes);
|
||||
void AttachNodesToCursor(const QVector<Node *> &nodes);
|
||||
|
||||
void AttachItemsToCursor(const QList<NodeViewItem*>& items);
|
||||
void AttachItemsToCursor(const QVector<NodeViewItem *> &items);
|
||||
|
||||
void DetachItemsFromCursor();
|
||||
|
||||
@@ -121,13 +121,13 @@ private:
|
||||
|
||||
NodeViewScene scene_;
|
||||
|
||||
QList<Node*> selected_nodes_;
|
||||
QVector<Node*> selected_nodes_;
|
||||
|
||||
QList<Block*> selected_blocks_;
|
||||
QVector<Block*> selected_blocks_;
|
||||
|
||||
QHash<Node*, QList<Block*> > association_map_;
|
||||
QHash<Node*, QVector<Block*> > association_map_;
|
||||
|
||||
QHash<Block*, QList<Node*> > temporary_association_map_;
|
||||
QHash<Block*, QVector<Node*> > temporary_association_map_;
|
||||
|
||||
enum FilterMode {
|
||||
kFilterShowAll,
|
||||
|
||||
@@ -120,10 +120,10 @@ void NodeViewScene::SetGraph(NodeGraph *graph)
|
||||
graph_ = graph;
|
||||
}
|
||||
|
||||
QList<Node *> NodeViewScene::GetSelectedNodes() const
|
||||
QVector<Node *> NodeViewScene::GetSelectedNodes() const
|
||||
{
|
||||
QHash<Node*, NodeViewItem*>::const_iterator iterator;
|
||||
QList<Node *> selected;
|
||||
QVector<Node *> selected;
|
||||
|
||||
for (iterator=item_map_.begin();iterator!=item_map_.end();iterator++) {
|
||||
if (iterator.value()->isSelected()) {
|
||||
@@ -134,10 +134,10 @@ QList<Node *> NodeViewScene::GetSelectedNodes() const
|
||||
return selected;
|
||||
}
|
||||
|
||||
QList<NodeViewItem *> NodeViewScene::GetSelectedItems() const
|
||||
QVector<NodeViewItem *> NodeViewScene::GetSelectedItems() const
|
||||
{
|
||||
QHash<Node*, NodeViewItem*>::const_iterator iterator;
|
||||
QList<NodeViewItem *> selected;
|
||||
QVector<NodeViewItem *> selected;
|
||||
|
||||
for (iterator=item_map_.begin();iterator!=item_map_.end();iterator++) {
|
||||
if (iterator.value()->isSelected()) {
|
||||
@@ -148,9 +148,9 @@ QList<NodeViewItem *> NodeViewScene::GetSelectedItems() const
|
||||
return selected;
|
||||
}
|
||||
|
||||
QList<NodeEdge*> NodeViewScene::GetSelectedEdges() const
|
||||
QVector<NodeEdge*> NodeViewScene::GetSelectedEdges() const
|
||||
{
|
||||
QList<NodeEdge*> edges;
|
||||
QVector<NodeEdge*> edges;
|
||||
|
||||
QHash<NodeEdge*, NodeViewEdge*>::const_iterator i;
|
||||
|
||||
@@ -228,7 +228,7 @@ void NodeViewScene::RemoveEdge(NodeEdgePtr edge)
|
||||
|
||||
int NodeViewScene::DetermineWeight(Node *n)
|
||||
{
|
||||
QList<Node*> inputs = n->GetImmediateDependencies();
|
||||
QVector<Node*> inputs = n->GetImmediateDependencies();
|
||||
|
||||
int weight = 0;
|
||||
|
||||
@@ -253,7 +253,7 @@ NodeViewCommon::FlowDirection NodeViewScene::GetFlowDirection() const
|
||||
|
||||
void NodeViewScene::ReorganizeFrom(Node* n)
|
||||
{
|
||||
QList<Node*> immediates = n->GetImmediateDependencies();
|
||||
QVector<Node*> immediates = n->GetImmediateDependencies();
|
||||
|
||||
if (immediates.isEmpty()) {
|
||||
// Nothing to do
|
||||
|
||||
@@ -63,9 +63,9 @@ public:
|
||||
|
||||
void SetGraph(NodeGraph* graph);
|
||||
|
||||
QList<Node*> GetSelectedNodes() const;
|
||||
QList<NodeViewItem*> GetSelectedItems() const;
|
||||
QList<NodeEdge *> GetSelectedEdges() const;
|
||||
QVector<Node *> GetSelectedNodes() const;
|
||||
QVector<NodeViewItem*> GetSelectedItems() const;
|
||||
QVector<NodeEdge *> GetSelectedEdges() const;
|
||||
|
||||
const QHash<Node*, NodeViewItem*>& item_map() const;
|
||||
const QHash<NodeEdge*, NodeViewEdge*>& edge_map() const;
|
||||
|
||||
@@ -131,7 +131,7 @@ Project *NodeAddCommand::GetRelevantProject() const
|
||||
return static_cast<Sequence*>(graph_)->project();
|
||||
}
|
||||
|
||||
NodeRemoveCommand::NodeRemoveCommand(NodeGraph *graph, const QList<Node *> &nodes, QUndoCommand *parent) :
|
||||
NodeRemoveCommand::NodeRemoveCommand(NodeGraph *graph, const QVector<Node *> &nodes, QUndoCommand *parent) :
|
||||
UndoCommand(parent),
|
||||
graph_(graph),
|
||||
nodes_(nodes)
|
||||
@@ -197,7 +197,7 @@ Project *NodeRemoveCommand::GetRelevantProject() const
|
||||
NodeRemoveWithExclusiveDeps::NodeRemoveWithExclusiveDeps(NodeGraph *graph, Node *node, QUndoCommand *parent) :
|
||||
UndoCommand(parent)
|
||||
{
|
||||
QList<Node*> node_and_its_deps;
|
||||
QVector<Node*> node_and_its_deps;
|
||||
node_and_its_deps.append(node);
|
||||
node_and_its_deps.append(node->GetExclusiveDependencies());
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
class NodeRemoveCommand : public UndoCommand {
|
||||
public:
|
||||
NodeRemoveCommand(NodeGraph* graph,
|
||||
const QList<Node*>& nodes,
|
||||
const QVector<Node*>& nodes,
|
||||
QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
@@ -111,9 +111,9 @@ private:
|
||||
QObject memory_manager_;
|
||||
|
||||
NodeGraph* graph_;
|
||||
QList<Node*> nodes_;
|
||||
QList<NodeEdgePtr> edges_;
|
||||
QList<BlockUnlinkAllCommand*> block_unlink_commands_;
|
||||
QVector<Node*> nodes_;
|
||||
QVector<NodeEdgePtr> edges_;
|
||||
QVector<BlockUnlinkAllCommand*> block_unlink_commands_;
|
||||
};
|
||||
|
||||
class NodeRemoveWithExclusiveDeps : public UndoCommand {
|
||||
|
||||
Reference in New Issue
Block a user