nodeparamview: improved performance
This commit is contained in:
@@ -137,8 +137,6 @@ NodeParamView::NodeParamView(QWidget *parent) :
|
||||
|
||||
void NodeParamView::SelectNodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
qint64 t = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
int original_node_count = items_.size();
|
||||
|
||||
foreach (Node* n, nodes) {
|
||||
@@ -162,14 +160,10 @@ void NodeParamView::SelectNodes(const QVector<Node *> &nodes)
|
||||
|
||||
SignalNodeOrder();
|
||||
}
|
||||
|
||||
qDebug() << "SelectNodes took" << (QDateTime::currentMSecsSinceEpoch() - t) << "with" << nodes.size() << "nodes";
|
||||
}
|
||||
|
||||
void NodeParamView::DeselectNodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
qint64 t = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
// Remove item from map and delete the widget
|
||||
int original_node_count = items_.size();
|
||||
|
||||
@@ -196,8 +190,6 @@ void NodeParamView::DeselectNodes(const QVector<Node *> &nodes)
|
||||
|
||||
SignalNodeOrder();
|
||||
}
|
||||
|
||||
qDebug() << "DeselectNodes took" << (QDateTime::currentMSecsSinceEpoch() - t) << "with" << nodes.size() << "nodes";
|
||||
}
|
||||
|
||||
void NodeParamView::resizeEvent(QResizeEvent *event)
|
||||
|
||||
@@ -245,10 +245,9 @@ NodeParamViewItemBody::NodeParamViewItemBody(Node* node, QWidget *parent) :
|
||||
|
||||
root_layout->addWidget(array_widget, insert_row, 1, 1, 10);
|
||||
|
||||
int arr_sz = node->InputArraySize(input);
|
||||
for (int j=0; j<arr_sz; j++) {
|
||||
CreateWidgets(array_layout, node, input, j, j);
|
||||
}
|
||||
// Start with zero elements for efficiency. We will make the widgets for them if the user
|
||||
// requests the array UI to be expanded
|
||||
int arr_sz = 0;
|
||||
|
||||
// Add one last add button for appending to the array
|
||||
NodeParamViewArrayButton* append_btn = new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd);
|
||||
@@ -462,21 +461,8 @@ void NodeParamViewItemBody::PlaceWidgetsFromBridge(QGridLayout* layout, NodePara
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ArrayCollapseBtnPressed(bool checked)
|
||||
void NodeParamViewItemBody::InputArraySizeChangedInternal(Node *node, const QString &input, int size)
|
||||
{
|
||||
const NodeInputPair& input = array_collapse_buttons_.key(static_cast<CollapseButton*>(sender()));
|
||||
|
||||
array_ui_.value(input).widget->setVisible(checked);
|
||||
|
||||
emit ArrayExpandedChanged(checked);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::InputArraySizeChanged(const QString& input, int old_sz, int size)
|
||||
{
|
||||
Q_UNUSED(old_sz)
|
||||
|
||||
Node* node = static_cast<Node*>(sender());
|
||||
|
||||
ArrayUI& array_ui = array_ui_[{node, input}];
|
||||
|
||||
if (size != array_ui.count) {
|
||||
@@ -506,9 +492,31 @@ void NodeParamViewItemBody::InputArraySizeChanged(const QString& input, int old_
|
||||
}
|
||||
|
||||
array_ui.count = size;
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ArrayCollapseBtnPressed(bool checked)
|
||||
{
|
||||
const NodeInputPair& input = array_collapse_buttons_.key(static_cast<CollapseButton*>(sender()));
|
||||
|
||||
array_ui_.value(input).widget->setVisible(checked);
|
||||
if (checked) {
|
||||
// Ensure widgets are created (the signal will be ignored if they are)
|
||||
InputArraySizeChangedInternal(input.node, input.input, input.node->InputArraySize(input.input));
|
||||
}
|
||||
|
||||
Retranslate();
|
||||
emit ArrayExpandedChanged(checked);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::InputArraySizeChanged(const QString& input, int old_sz, int size)
|
||||
{
|
||||
Q_UNUSED(old_sz)
|
||||
|
||||
Node* node = static_cast<Node*>(sender());
|
||||
|
||||
InputArraySizeChangedInternal(node, input, size);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ArrayAppendClicked()
|
||||
|
||||
@@ -102,6 +102,8 @@ private:
|
||||
|
||||
void PlaceWidgetsFromBridge(QGridLayout *layout, NodeParamViewWidgetBridge* bridge, int row);
|
||||
|
||||
void InputArraySizeChangedInternal(Node *node, const QString &input, int size);
|
||||
|
||||
struct InputUI {
|
||||
InputUI();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user