X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FCollectionPlugin%2FCollectionPlugin_WidgetField.cpp;h=f1a5109eff7776b5efcb25e149698b1e29a4e433;hb=refs%2Fheads%2FV9_11_BR;hp=bdb55bdf3b549f63af391edc6403a8ef12e5d624;hpb=5ad9fef3d46416ae3e852aa4bd5816598f21b1de;p=modules%2Fshaper.git diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp index bdb55bdf3..f1a5109ef 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp @@ -1,8 +1,21 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: CollectionPlugin_WidgetField.cpp -// Created: 16 Nov 2016 -// Author: Vitaly SMETANNIKOV +// Copyright (C) 2014-2023 CEA, EDF +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "CollectionPlugin_WidgetField.h" #include "CollectionPlugin_Field.h" @@ -89,20 +102,21 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, aEditor = QStyledItemDelegate::createEditor(theParent, theOption, theIndex); } } - QObject* aThat = (QObject*) this; - aEditor->installEventFilter(aThat); + if (myType == ModelAPI_AttributeTables::BOOLEAN) + connect(aEditor, SIGNAL(currentTextChanged(const QString&)), + SLOT(onEditItem(const QString&))); + else + connect(aEditor, SIGNAL(textEdited(const QString&)), + SLOT(onEditItem(const QString&))); return aEditor; } -//bool DataTableItemDelegate::eventFilter(QObject* theObj, QEvent* theEvent) -//{ -// qDebug("### Type = %i", theEvent->type()); -// if (theEvent->type() == QEvent::Close) { -// QWidget* aWgt = dynamic_cast(theObj); -// commitData(aWgt); -// } -// return QStyledItemDelegate::eventFilter(theObj, theEvent); -//} +void DataTableItemDelegate::onEditItem(const QString& theText) +{ + QWidget* aWgt = dynamic_cast(sender()); + commitData(aWgt); +} + //********************************************************************************** @@ -484,7 +498,6 @@ bool CollectionPlugin_WidgetField::storeValueCustom() } } } - updateObject(myFeature); return true; } @@ -498,7 +511,9 @@ bool CollectionPlugin_WidgetField::restoreValueCustom() std::string aTypeStr = aSelList->selectionType(); if (aTypeStr == "") return false; // The attribute is not initialized + isBlocked = myShapeTypeCombo->blockSignals(true); myShapeTypeCombo->setCurrentIndex(getSelectionType(aTypeStr)); + myShapeTypeCombo->blockSignals(isBlocked); // Get number of components AttributeStringArrayPtr aStringsAttr = @@ -563,9 +578,9 @@ bool CollectionPlugin_WidgetField::restoreValueCustom() // Add selection names AttributeSelectionPtr aAttr = aSelList->value(k - 1); if (aItem) { - aItem->setText(aAttr->namingName().c_str()); + aItem->setText(QString::fromStdWString(aAttr->namingName())); } else { - aItem = new QTableWidgetItem(aAttr->namingName().c_str()); + aItem = new QTableWidgetItem(QString::fromStdWString(aAttr->namingName())); aTable->setItem(k, j, aItem); } } else if (j > 0) { @@ -583,9 +598,9 @@ bool CollectionPlugin_WidgetField::restoreValueCustom() } } // Restore columns width - for (int i = 0; i < aTable->columnCount(); i++) { - if (i < aColWidth.size()) - aTable->setColumnWidth(i, aColWidth.at(i)); + for (int col = 0; col < aTable->columnCount(); col++) { + if (col < aColWidth.size()) + aTable->setColumnWidth(col, aColWidth.at(col)); } aTable->blockSignals(isBlocked); @@ -754,8 +769,8 @@ void CollectionPlugin_WidgetField::onAddStep() aTable->setItem(j, i, aItem); } AttributeSelectionPtr aAttr = aSelList->value(j - 1); - aItem->setText(aAttr->namingName().c_str()); - aItem->setToolTip(aAttr->namingName().c_str()); + aItem->setText(QString::fromStdWString(aAttr->namingName())); + aItem->setToolTip(QString::fromStdWString(aAttr->namingName())); } } else { QString aDefVal = aTable->item(0, i)->text(); @@ -825,8 +840,12 @@ bool CollectionPlugin_WidgetField:: for (anIt = theValues.begin(); anIt != theValues.end(); anIt++) { ModuleBase_ViewerPrsPtr aValue = *anIt; ResultPtr aRes = std::dynamic_pointer_cast(aValue->object()); - if (theToValidate && aRes.get() && acceptSubShape(aValue->shape(), aRes)) - aSelected.append(aValue); + if (theToValidate && aRes.get()) { + if (myShapeTypeCombo->currentIndex() > 3) + aSelected.append(aValue); + else if (acceptSubShape(aValue->shape(), aRes)) + aSelected.append(aValue); + } } AttributeSelectionListPtr aSelList = myFeature->data()->selectionList(CollectionPlugin_Field::SELECTED_ID()); @@ -866,8 +885,8 @@ bool CollectionPlugin_WidgetField:: aTable->setItem(j, i, aItem); } AttributeSelectionPtr aAttr = aSelList->value(j - 1); - aItem->setText(aAttr->namingName().c_str()); - aItem->setToolTip(aAttr->namingName().c_str()); + aItem->setText(QString::fromStdWString(aAttr->namingName())); + aItem->setToolTip(QString::fromStdWString(aAttr->namingName())); } } else { QString aDefVal = aTable->item(0, i)->text(); @@ -885,8 +904,8 @@ bool CollectionPlugin_WidgetField:: // Update only selection name for(int j = 1; j < aNewRows - 1; j++) { AttributeSelectionPtr aAttr = aSelList->value(j); - aTable->item(j, 0)->setText(aAttr->namingName().c_str()); - aTable->item(j, 0)->setToolTip(aAttr->namingName().c_str()); + aTable->item(j, 0)->setText(QString::fromStdWString(aAttr->namingName())); + aTable->item(j, 0)->setToolTip(QString::fromStdWString(aAttr->namingName())); } } } @@ -947,7 +966,7 @@ void CollectionPlugin_WidgetField::onTableEdited(int theRow, int theCol) //********************************************************************************** void CollectionPlugin_WidgetField::onShapeTypeChanged(int theType) { - activateSelectionAndFilters(theType == 5? false:true); + updateSelectionModesAndFilters(theType == 5? false:true); AttributeSelectionListPtr aSelList = myFeature->data()->selectionList(CollectionPlugin_Field::SELECTED_ID()); @@ -956,12 +975,16 @@ void CollectionPlugin_WidgetField::onShapeTypeChanged(int theType) if (aTypeName == aSelList->selectionType()) return; aSelList->setSelectionType(aTypeName); + // Updated event has to be sent here in case if type of shapes + // was changed from Part to any other in order to updater Apply button status + myFeature->data()->sendAttributeUpdated(aSelList.get()); //Clear old selection clearData(); aSelList->clear(); AttributeTablesPtr aTablesAttr = myFeature->data()->tables(CollectionPlugin_Field::VALUES_ID()); aTablesAttr->setSize(1, myNbComponentsSpn->value(), myDataTblList.size()); + updateObject(myFeature); emit valuesChanged(); }