From 565a012b6c03346c3caa38e99355a8cdae80e6c1 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 9 Feb 2016 19:40:59 +0000 Subject: [PATCH] Show piece properties that are the same when multiple pieces are selected. --- qt/lc_qpropertiestree.cpp | 46 ++++++++++++++++++++++++++++++++++----- qt/lc_qpropertiestree.h | 2 +- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index d1e2b685..b45d40f8 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -426,7 +426,7 @@ void lcQPropertiesTree::Update(const lcArray& Selection, lcObject* Fo break; case LC_PROPERTY_WIDGET_PIECE: - SetPiece(Focus); + SetPiece(Selection, Focus); break; case LC_PROPERTY_WIDGET_CAMERA: @@ -839,7 +839,7 @@ void lcQPropertiesTree::SetEmpty() mFocus = NULL; } -void lcQPropertiesTree::SetPiece(lcObject* Focus) +void lcQPropertiesTree::SetPiece(const lcArray& Selection, lcObject* Focus) { if (mWidgetMode != LC_PROPERTY_WIDGET_PIECE) { @@ -893,7 +893,6 @@ void lcQPropertiesTree::SetPiece(lcObject* Focus) lcStep Show = 0; lcStep Hide = 0; int ColorIndex = gDefaultColor; - const char* Description = ""; PieceInfo* Info = NULL; if (Piece) @@ -901,9 +900,46 @@ void lcQPropertiesTree::SetPiece(lcObject* Focus) Show = Piece->GetStepShow(); Hide = Piece->GetStepHide(); ColorIndex = Piece->mColorIndex; - Description = Piece->mPieceInfo->m_strDescription; Info = Piece->mPieceInfo; } + else + { + bool FirstPiece = true; + + for (int ObjectIdx = 0; ObjectIdx < Selection.GetSize(); ObjectIdx++) + { + lcObject* Object = Selection[ObjectIdx]; + + if (Object->GetType() != LC_OBJECT_PIECE) + continue; + + lcPiece* SelectedPiece = (lcPiece*)Object; + + if (FirstPiece) + { + Show = SelectedPiece->GetStepShow(); + Hide = SelectedPiece->GetStepHide(); + ColorIndex = SelectedPiece->mColorIndex; + Info = SelectedPiece->mPieceInfo; + + FirstPiece = false; + } + else + { + if (SelectedPiece->GetStepShow() != Show) + Show = 0; + + if (SelectedPiece->GetStepHide() != Hide) + Hide = 0; + + if (SelectedPiece->mColorIndex != ColorIndex) + ColorIndex = gDefaultColor; + + if (SelectedPiece->mPieceInfo != Info) + Info = NULL; + } + } + } partShow->setText(1, QString::number(Show)); partShow->setData(0, PropertyValueRole, Show); @@ -925,7 +961,7 @@ void lcQPropertiesTree::SetPiece(lcObject* Focus) partColor->setText(1, color->Name); partColor->setData(0, PropertyValueRole, ColorIndex); - partID->setText(1, Description); + partID->setText(1, Info ? Info->m_strDescription : QString()); partID->setData(0, PropertyValueRole, qVariantFromValue((void*)Info)); } diff --git a/qt/lc_qpropertiestree.h b/qt/lc_qpropertiestree.h index 95760727..745a2968 100644 --- a/qt/lc_qpropertiestree.h +++ b/qt/lc_qpropertiestree.h @@ -66,7 +66,7 @@ protected: QTreeWidgetItem *addProperty(QTreeWidgetItem *parent, const QString& label, PropertyType propertyType); void SetEmpty(); - void SetPiece(lcObject* Focus); + void SetPiece(const lcArray& Selection, lcObject* Focus); void SetCamera(lcObject* Focus); void SetLight(lcObject* Focus); void SetMultiple();