Clear selection when switch active sheet.

This commit is contained in:
Roman Telezhynskyi 2021-09-06 17:44:27 +03:00
parent b71253738c
commit 7b134d8b62
4 changed files with 31 additions and 13 deletions

View File

@ -203,6 +203,12 @@ void VPCarrousel::on_ActivePieceListChanged(int index)
if (not sheet.isNull()) if (not sheet.isNull())
{ {
VPSheetPtr activeSheet = layout->GetFocusedSheet();
if (not activeSheet.isNull())
{
activeSheet->ClearSelection();
}
m_ignoreActiveSheetChange = true; m_ignoreActiveSheetChange = true;
layout->SetFocusedSheet(sheet); layout->SetFocusedSheet(sheet);
m_ignoreActiveSheetChange = false; m_ignoreActiveSheetChange = false;

View File

@ -595,6 +595,28 @@ auto VPSheet::SceneData() const -> VPSheetSceneData *
return m_sceneData; return m_sceneData;
} }
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::ClearSelection() const
{
QList<VPPiecePtr> selectedPieces = GetSelectedPieces();
for (const auto& piece : selectedPieces)
{
if (piece->IsSelected())
{
piece->SetSelected(false);
}
}
if (not selectedPieces.isEmpty())
{
VPLayoutPtr layout = GetLayout();
if (not layout.isNull())
{
emit GetLayout()->PieceSelectionChanged(VPPiecePtr());
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSheet::SheetUnits() const -> Unit auto VPSheet::SheetUnits() const -> Unit
{ {

View File

@ -255,6 +255,8 @@ public:
VPSheetSceneData *SceneData() const; VPSheetSceneData *SceneData() const;
void ClearSelection() const;
public slots: public slots:
void CheckPiecePositionValidity(const VPPiecePtr &piece) const; void CheckPiecePositionValidity(const VPPiecePtr &piece) const;

View File

@ -457,19 +457,7 @@ void VPMainGraphicsView::on_ItemClicked(QGraphicsItem *item)
VPSheetPtr sheet = layout->GetFocusedSheet(); VPSheetPtr sheet = layout->GetFocusedSheet();
if (not sheet.isNull()) if (not sheet.isNull())
{ {
QList<VPPiecePtr> selectedPieces = sheet->GetSelectedPieces(); sheet->ClearSelection();
for (const auto& piece : selectedPieces)
{
if (piece->IsSelected())
{
piece->SetSelected(false);
}
}
if (not selectedPieces.isEmpty())
{
emit layout->PieceSelectionChanged(VPPiecePtr());
}
} }
} }
} }