Skip to content

Commit

Permalink
Update parts in use category after changes. Fixes #890.
Browse files Browse the repository at this point in the history
  • Loading branch information
leozide committed Nov 15, 2024
1 parent dd3ab89 commit 72c8e7a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions common/lc_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2297,6 +2297,11 @@ void lcMainWindow::UpdateModels()
SetCurrentPieceInfo(nullptr);
}

void lcMainWindow::UpdateInUseCategory()
{
mPartSelectionWidget->UpdateInUseCategory();
}

void lcMainWindow::UpdateCategories()
{
mPartSelectionWidget->UpdateCategories();
Expand Down
1 change: 1 addition & 0 deletions common/lc_mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ class lcMainWindow : public QMainWindow
void UpdateShadingMode();
void UpdateSelectionMode();
void UpdateModels();
void UpdateInUseCategory();
void UpdateCategories();
void UpdateTitle();
void UpdateModified(bool Modified);
Expand Down
11 changes: 10 additions & 1 deletion common/lc_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,9 +2355,12 @@ void lcModel::DeleteSelectedObjects()
{
if (RemoveSelectedObjects())
{
if (!mIsPreview) {
if (!mIsPreview)
{
gMainWindow->UpdateTimeline(false, false);
gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateInUseCategory();

UpdateAllViews();
SaveCheckpoint(tr("Deleting"));
}
Expand Down Expand Up @@ -3182,6 +3185,12 @@ void lcModel::SetObjectsProperty(const std::vector<lcObject*>& Objects, lcObject
{
gMainWindow->UpdateTimeline(false, true);
}

// todo: fix hacky category update
if (PropertyId == lcObjectPropertyId::PieceId)
{
gMainWindow->UpdateInUseCategory();
}
}

bool lcModel::AnyPiecesSelected() const
Expand Down
11 changes: 11 additions & 0 deletions common/lc_partselectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,12 @@ void lcPartSelectionListView::ToggleFixedColor()
mListModel->ToggleColorLocked();
}

void lcPartSelectionListView::UpdateInUseCategory()
{
if (mCategoryType == lcPartCategoryType::PartsInUse)
mListModel->SetCurrentModelCategory();
}

void lcPartSelectionListView::UpdateViewMode()
{
setViewMode(mListModel->GetIconSize() && !mListModel->IsListMode() ? QListView::IconMode : QListView::ListMode);
Expand Down Expand Up @@ -1112,6 +1118,11 @@ void lcPartSelectionWidget::RemoveFromPalette()
}
}

void lcPartSelectionWidget::UpdateInUseCategory()
{
mPartsWidget->UpdateInUseCategory();
}

void lcPartSelectionWidget::UpdateCategories()
{
QTreeWidgetItem* CurrentItem = mCategoriesWidget->currentItem();
Expand Down
2 changes: 2 additions & 0 deletions common/lc_partselectionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class lcPartSelectionListView : public QListView
return mContextInfo;
}

void UpdateInUseCategory();
void UpdateViewMode();

public slots:
Expand Down Expand Up @@ -212,6 +213,7 @@ class lcPartSelectionWidget : public QWidget
void UpdateThumbnails();
void SetDefaultPart();
void UpdateModels();
void UpdateInUseCategory();
void UpdateCategories();
void LoadState(QSettings& Settings);
void SaveState(QSettings& Settings);
Expand Down

0 comments on commit 72c8e7a

Please sign in to comment.