Sketcher: Disable visibility checkbox for external geometry

This commit is contained in:
Kacper Donat
2024-01-21 19:47:42 +01:00
parent 8c2310eaf3
commit 993248b4db
3 changed files with 120 additions and 7 deletions

View File

@@ -193,7 +193,12 @@ public:
~ElementItem() override
{}
bool isVisible()
bool canBeHidden() const
{
return State != GeometryState::External;
}
bool isVisible() const
{
if (State != GeometryState::External) {
const auto geo = sketchView->getSketchObject()->getGeometry(ElementNbr);
@@ -957,10 +962,14 @@ void ElementItemDelegate::drawSubControl(SubControl element,
QStyleOptionButton checkboxOption;
checkboxOption.initFrom(option.widget);
checkboxOption.state |= QStyle::State_Enabled;
checkboxOption.rect = rect;
checkboxOption.state.setFlag(QStyle::State_Enabled, item->canBeHidden());
if (isHovered) {
checkboxOption.state |= QStyle::State_MouseOver;
}
if (item->isVisible()) {
checkboxOption.state |= QStyle::State_On;
}
@@ -1040,10 +1049,12 @@ bool ElementItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,
item->clickedOn = getSubElementType(mouseEvent->pos());
item->rightClicked = mouseEvent->button() == Qt::RightButton;
QRect checkboxRect = subControlRect(SubControl::CheckBox, option, index);
if (item->canBeHidden()) {
QRect checkboxRect = subControlRect(SubControl::CheckBox, option, index);
if (mouseEvent->button() == Qt::LeftButton && checkboxRect.contains(mouseEvent->pos())) {
Q_EMIT itemChecked(index, item->isVisible() ? Qt::Unchecked : Qt::Checked);
if (mouseEvent->button() == Qt::LeftButton && checkboxRect.contains(mouseEvent->pos())) {
Q_EMIT itemChecked(index, item->isVisible() ? Qt::Unchecked : Qt::Checked);
}
}
}
else if (event->type() == QEvent::MouseMove) {
@@ -1056,7 +1067,7 @@ bool ElementItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,
return QStyledItemDelegate::editorEvent(event, model, option, index);
}
const QWidget *w
ElementItem* ElementItemDelegate::getElementItem(const QModelIndex& index) const
{
ElementView* elementView = static_cast<ElementView*>(parent());