Update parts in use category after changes. Fixes #890.
Some checks failed
LeoCAD CI / build-ubuntu (push) Has been cancelled
LeoCAD CI / build-macos (push) Has been cancelled

This commit is contained in:
Leonardo Zide 2024-11-14 17:28:51 -08:00
parent dd3ab8990e
commit 72c8e7a6c2
5 changed files with 29 additions and 1 deletions

View file

@ -2297,6 +2297,11 @@ void lcMainWindow::UpdateModels()
SetCurrentPieceInfo(nullptr); SetCurrentPieceInfo(nullptr);
} }
void lcMainWindow::UpdateInUseCategory()
{
mPartSelectionWidget->UpdateInUseCategory();
}
void lcMainWindow::UpdateCategories() void lcMainWindow::UpdateCategories()
{ {
mPartSelectionWidget->UpdateCategories(); mPartSelectionWidget->UpdateCategories();

View file

@ -272,6 +272,7 @@ public:
void UpdateShadingMode(); void UpdateShadingMode();
void UpdateSelectionMode(); void UpdateSelectionMode();
void UpdateModels(); void UpdateModels();
void UpdateInUseCategory();
void UpdateCategories(); void UpdateCategories();
void UpdateTitle(); void UpdateTitle();
void UpdateModified(bool Modified); void UpdateModified(bool Modified);

View file

@ -2355,9 +2355,12 @@ void lcModel::DeleteSelectedObjects()
{ {
if (RemoveSelectedObjects()) if (RemoveSelectedObjects())
{ {
if (!mIsPreview) { if (!mIsPreview)
{
gMainWindow->UpdateTimeline(false, false); gMainWindow->UpdateTimeline(false, false);
gMainWindow->UpdateSelectedObjects(true); gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateInUseCategory();
UpdateAllViews(); UpdateAllViews();
SaveCheckpoint(tr("Deleting")); SaveCheckpoint(tr("Deleting"));
} }
@ -3182,6 +3185,12 @@ void lcModel::SetObjectsProperty(const std::vector<lcObject*>& Objects, lcObject
{ {
gMainWindow->UpdateTimeline(false, true); gMainWindow->UpdateTimeline(false, true);
} }
// todo: fix hacky category update
if (PropertyId == lcObjectPropertyId::PieceId)
{
gMainWindow->UpdateInUseCategory();
}
} }
bool lcModel::AnyPiecesSelected() const bool lcModel::AnyPiecesSelected() const

View file

@ -581,6 +581,12 @@ void lcPartSelectionListView::ToggleFixedColor()
mListModel->ToggleColorLocked(); mListModel->ToggleColorLocked();
} }
void lcPartSelectionListView::UpdateInUseCategory()
{
if (mCategoryType == lcPartCategoryType::PartsInUse)
mListModel->SetCurrentModelCategory();
}
void lcPartSelectionListView::UpdateViewMode() void lcPartSelectionListView::UpdateViewMode()
{ {
setViewMode(mListModel->GetIconSize() && !mListModel->IsListMode() ? QListView::IconMode : QListView::ListMode); setViewMode(mListModel->GetIconSize() && !mListModel->IsListMode() ? QListView::IconMode : QListView::ListMode);
@ -1112,6 +1118,11 @@ void lcPartSelectionWidget::RemoveFromPalette()
} }
} }
void lcPartSelectionWidget::UpdateInUseCategory()
{
mPartsWidget->UpdateInUseCategory();
}
void lcPartSelectionWidget::UpdateCategories() void lcPartSelectionWidget::UpdateCategories()
{ {
QTreeWidgetItem* CurrentItem = mCategoriesWidget->currentItem(); QTreeWidgetItem* CurrentItem = mCategoriesWidget->currentItem();

View file

@ -177,6 +177,7 @@ public:
return mContextInfo; return mContextInfo;
} }
void UpdateInUseCategory();
void UpdateViewMode(); void UpdateViewMode();
public slots: public slots:
@ -212,6 +213,7 @@ public:
void UpdateThumbnails(); void UpdateThumbnails();
void SetDefaultPart(); void SetDefaultPart();
void UpdateModels(); void UpdateModels();
void UpdateInUseCategory();
void UpdateCategories(); void UpdateCategories();
void LoadState(QSettings& Settings); void LoadState(QSettings& Settings);
void SaveState(QSettings& Settings); void SaveState(QSettings& Settings);