projectpanel: select nodes when items are selected in the project explorer
This commit is contained in:
@@ -57,6 +57,7 @@ ProjectPanel::ProjectPanel(QWidget *parent) :
|
||||
explorer_ = new ProjectExplorer(this);
|
||||
layout->addWidget(explorer_);
|
||||
connect(explorer_, &ProjectExplorer::DoubleClickedItem, this, &ProjectPanel::ItemDoubleClickSlot);
|
||||
connect(explorer_, &ProjectExplorer::SelectionChanged, this, &ProjectPanel::SelectionChanged);
|
||||
|
||||
// Set toolbar's view to the explorer's view
|
||||
toolbar->SetView(explorer_->view_type());
|
||||
|
||||
@@ -66,6 +66,8 @@ public slots:
|
||||
signals:
|
||||
void ProjectNameChanged();
|
||||
|
||||
void SelectionChanged(const QVector<Node *> &selected);
|
||||
|
||||
private:
|
||||
virtual void Retranslate() override;
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ void ProjectExplorer::AddView(QAbstractItemView *view)
|
||||
view->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
connect(view, &QAbstractItemView::clicked, this, &ProjectExplorer::ItemClickedSlot);
|
||||
connect(view, &QAbstractItemView::doubleClicked, this, &ProjectExplorer::ItemDoubleClickedSlot);
|
||||
connect(view->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ProjectExplorer::ViewSelectionChanged);
|
||||
connect(view, SIGNAL(DoubleClickedEmptyArea()), this, SLOT(ViewEmptyAreaDoubleClickedSlot()));
|
||||
stacked_widget_->addWidget(view);
|
||||
}
|
||||
@@ -509,6 +510,28 @@ void ProjectExplorer::ContextMenuStartProxy(QAction *a)
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorer::ViewSelectionChanged()
|
||||
{
|
||||
QItemSelectionModel *model = static_cast<QItemSelectionModel *>(sender());
|
||||
|
||||
QModelIndexList selection = model->selectedIndexes();
|
||||
|
||||
QVector<Node *> nodes;
|
||||
|
||||
foreach (const QModelIndex &index, selection) {
|
||||
Node *sel = static_cast<Node*>(sort_model_.mapToSource(index).internalPointer());
|
||||
if (!nodes.contains(sel)) {
|
||||
nodes.append(sel);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodes.isEmpty()) {
|
||||
nodes.append(get_root());
|
||||
}
|
||||
|
||||
emit SelectionChanged(nodes);
|
||||
}
|
||||
|
||||
Project *ProjectExplorer::project() const
|
||||
{
|
||||
return model_.project();
|
||||
|
||||
@@ -100,6 +100,8 @@ signals:
|
||||
*/
|
||||
void DoubleClickedItem(Node* item);
|
||||
|
||||
void SelectionChanged(const QVector<Node *> &selected);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Get all the blocks that solely rely on an input node
|
||||
@@ -185,6 +187,8 @@ private slots:
|
||||
|
||||
void ContextMenuStartProxy(QAction* a);
|
||||
|
||||
void ViewSelectionChanged();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -475,6 +475,15 @@ void MainWindow::TimelinePanelSelectionChanged(const QVector<Block *> &blocks)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ProjectPanelSelectionChanged(const QVector<Node *> &nodes)
|
||||
{
|
||||
ProjectPanel *panel = static_cast<ProjectPanel *>(sender());
|
||||
|
||||
if (PanelManager::instance()->CurrentlyFocused(false) == panel) {
|
||||
node_panel_->Select(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
void MainWindow::ShowNouveauWarning()
|
||||
{
|
||||
@@ -564,6 +573,7 @@ ProjectPanel *MainWindow::AppendProjectPanel()
|
||||
|
||||
connect(panel, &PanelWidget::CloseRequested, this, &MainWindow::ProjectCloseRequested);
|
||||
connect(panel, &ProjectPanel::ProjectNameChanged, this, &MainWindow::UpdateTitle);
|
||||
connect(panel, &ProjectPanel::SelectionChanged, this, &MainWindow::ProjectPanelSelectionChanged);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -194,6 +194,8 @@ private slots:
|
||||
|
||||
void TimelinePanelSelectionChanged(const QVector<Block*> &blocks);
|
||||
|
||||
void ProjectPanelSelectionChanged(const QVector<Node*> &nodes);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user