X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FCollectionPlugin%2FCollectionPlugin_WidgetField.cpp;h=55b8066127e6f911fffde266df517c4a958f860f;hb=a6677508dfcc77446305c17509779accad261b54;hp=fcd7b89c2c19fa9278d3955e326a70222da83055;hpb=c64ac7a45d5276a777b52821245f405f5108fc0f;p=modules%2Fshaper.git diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp index fcd7b89c2..55b806612 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -39,29 +39,8 @@ const char* MYFirstCol = "Shape"; const char* MYTrue = "True"; const char* MYFalse = "False"; -class DataTableItemDelegate : public QStyledItemDelegate -{ -public: - DataTableItemDelegate(ModelAPI_AttributeTables::ValueType theType) : - QStyledItemDelegate() { myType = theType; } - - virtual QWidget* createEditor(QWidget* theParent, - const QStyleOptionViewItem & theOption, - const QModelIndex& theIndex) const; - - ModelAPI_AttributeTables::ValueType dataType() const { return myType; } - - void setDataType(ModelAPI_AttributeTables::ValueType theType) { myType = theType; } - -signals: - void startEditing(); - -private: - ModelAPI_AttributeTables::ValueType myType; -}; - -QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, - const QStyleOptionViewItem & theOption, +QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, + const QStyleOptionViewItem & theOption, const QModelIndex& theIndex ) const { if ((theIndex.column() == 0) && (theIndex.row() > 0)) { @@ -73,8 +52,8 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, QLineEdit* aLineEdt = 0; switch (myType) { case ModelAPI_AttributeTables::DOUBLE: - aLineEdt = dynamic_cast(QStyledItemDelegate::createEditor(theParent, - theOption, + aLineEdt = dynamic_cast(QStyledItemDelegate::createEditor(theParent, + theOption, theIndex)); if (aLineEdt) { aLineEdt->setValidator(new QDoubleValidator(aLineEdt)); @@ -82,15 +61,15 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, } break; case ModelAPI_AttributeTables::INTEGER: - aLineEdt = dynamic_cast(QStyledItemDelegate::createEditor(theParent, - theOption, + aLineEdt = dynamic_cast(QStyledItemDelegate::createEditor(theParent, + theOption, theIndex)); if (aLineEdt) { aLineEdt->setValidator(new QIntValidator(aLineEdt)); return aLineEdt; } break; - case ModelAPI_AttributeTables::BOOLEAN: + case ModelAPI_AttributeTables::BOOLEAN: { QComboBox* aBox = new QComboBox(theParent); aBox->addItem(MYFalse); @@ -108,11 +87,11 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, //********************************************************************************** //********************************************************************************** CollectionPlugin_WidgetField:: - CollectionPlugin_WidgetField(QWidget* theParent, - ModuleBase_IWorkshop* theWorkshop, + CollectionPlugin_WidgetField(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData): ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), - myIsEditing(false) + myIsTabEdit(false), myActivation(false) { QVBoxLayout* aMainLayout = new QVBoxLayout(this); @@ -125,7 +104,7 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), // Type of shapes myShapeTypeCombo = new QComboBox(aTypesWgt); QStringList aShapeTypes; - aShapeTypes << tr("Vertices") << tr("Edges") << tr("Faces") + aShapeTypes << tr("Vertices") << tr("Edges") << tr("Faces") << tr("Solids") << tr("Objects") << tr("Parts"); myShapeTypeCombo->addItems(aShapeTypes); aTypesLayout->addRow(tr("Type of shapes"), myShapeTypeCombo); @@ -133,7 +112,7 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), // Type of field myFieldTypeCombo = new QComboBox(aTypesWgt); QStringList aFieldTypes; - aFieldTypes << tr("Boolean") << tr("Integer") << tr("Double") + aFieldTypes << tr("Boolean") << tr("Integer") << tr("Double") << tr("String"); myFieldTypeCombo->addItems(aFieldTypes); myFieldTypeCombo->setCurrentIndex(2); @@ -180,6 +159,11 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), myCompNamesList << "Comp 1"; myStepWgt = new QStackedWidget(aStepFrame); aStepLayout->addWidget(myStepWgt, 2, 0, 1, 2); + + myDelegate = + new DataTableItemDelegate((ModelAPI_AttributeTables::ValueType) + myFieldTypeCombo->currentIndex()); + appendStepControls(); // Buttons below @@ -223,20 +207,24 @@ void CollectionPlugin_WidgetField::appendStepControls() // Data table QTableWidget* aDataTbl = new QTableWidget(1, myCompNamesList.count() + 1, aWidget); - DataTableItemDelegate* aDelegate = 0; - if (myDataTblList.isEmpty()) - aDelegate = new DataTableItemDelegate( - (ModelAPI_AttributeTables::ValueType) myFieldTypeCombo->currentIndex()); - else - aDelegate = dynamic_cast(myDataTblList.first()->itemDelegate()); - - aDataTbl->setItemDelegate(aDelegate); + aDataTbl->installEventFilter(this); + aDataTbl->setItemDelegate(myDelegate); + + QIntList aColWidth; + if (!myDataTblList.isEmpty()) { + QTableWidget* aFirstTable = myDataTblList.first(); + for (int i = 0; i < aFirstTable->columnCount(); i++) + aColWidth.append(aFirstTable->columnWidth(i)); + } myDataTblList.append(aDataTbl); aDataTbl->verticalHeader()->hide(); aDataTbl->setRowHeight(0, 25); aDataTbl->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); + connect(aDataTbl->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), + SLOT(onColumnResize(int, int, int))); + updateHeaders(aDataTbl); QTableWidgetItem* aItem = new QTableWidgetItem("Default value"); @@ -250,10 +238,16 @@ void CollectionPlugin_WidgetField::appendStepControls() aItem->setBackgroundColor(Qt::lightGray); aDataTbl->setItem(0, i + 1, aItem); } + + if (aColWidth.length() > 0) { + for (int i = 0; i < aDataTbl->columnCount(); i++) { + if (i < aColWidth.size()) + aDataTbl->setColumnWidth(i, aColWidth.at(i)); + } + } aStepLayout->addWidget(aDataTbl, 1, 0, 1, 2); connect(aDataTbl, SIGNAL(cellChanged(int, int)), SLOT(onTableEdited(int, int))); - QAbstractItemDelegate* aDel = aDataTbl->itemDelegate(); myStepWgt->addWidget(aWidget); aDataTbl->horizontalHeader()->viewport()->installEventFilter(this); } @@ -265,6 +259,13 @@ void CollectionPlugin_WidgetField::deactivate() storeValueCustom(); } +//********************************************************************************** +//void CollectionPlugin_WidgetField::showEvent(QShowEvent* theEvent) +//{ +// myShapeTypeCombo->setEnabled(!isEditingMode()); +// myFieldTypeCombo->setEnabled(!isEditingMode()); +// myNbComponentsSpn->setEnabled(!isEditingMode()); +//} //********************************************************************************** bool CollectionPlugin_WidgetField::eventFilter(QObject* theObject, QEvent* theEvent) @@ -315,11 +316,8 @@ bool CollectionPlugin_WidgetField::eventFilter(QObject* theObject, QEvent* theEv } } } else if ((theObject == myHeaderEditor) && (theEvent->type() == QEvent::FocusOut)) { - //QHeaderView* aHeader = - // static_cast(myHeaderEditor->parentWidget()->parentWidget()); QString aNewTitle = myHeaderEditor->text(); //save item text - //aHeader->model()->setHeaderData(myEditIndex, aHeader->orientation(), aNewTitle); myCompNamesList.replace(myEditIndex - 1, aNewTitle); myHeaderEditor->deleteLater(); //safely delete editor myHeaderEditor = 0; @@ -330,6 +328,15 @@ bool CollectionPlugin_WidgetField::eventFilter(QObject* theObject, QEvent* theEv foreach(QTableWidget* aTable, myDataTblList) { updateHeaders(aTable); } + } else if (theEvent->type() == QEvent::FocusIn) { + QTableWidget* aTable = dynamic_cast(theObject); + if (aTable) { + ModuleBase_IPropertyPanel* aPanel = myWorkshop->propertyPanel(); + if (aPanel->activeWidget() != this) { + myActivation = true; + aPanel->activateWidget(this, false); + } + } } return ModuleBase_WidgetSelector::eventFilter(theObject, theEvent); } @@ -343,9 +350,12 @@ QTableWidgetItem* CollectionPlugin_WidgetField::createDefaultItem() const case ModelAPI_AttributeTables::INTEGER: aItem->setText("0"); break; - case ModelAPI_AttributeTables::BOOLEAN: + case ModelAPI_AttributeTables::BOOLEAN: aItem->setText(MYFalse); break; + case ModelAPI_AttributeTables::STRING: + aItem->setText(""); + break; } return aItem; } @@ -355,22 +365,27 @@ QTableWidgetItem* CollectionPlugin_WidgetField:: createValueItem(ModelAPI_AttributeTables::Value& theVal) const { QTableWidgetItem* aItem = new QTableWidgetItem(); + aItem->setText(getValueText(theVal)); + return aItem; +} + +//********************************************************************************** +QString CollectionPlugin_WidgetField::getValueText(ModelAPI_AttributeTables::Value& theVal) const +{ switch (myFieldTypeCombo->currentIndex()) { case ModelAPI_AttributeTables::DOUBLE: - aItem->setText(QString::number(theVal.myDouble)); - break; + return QString::number(theVal.myDouble); case ModelAPI_AttributeTables::INTEGER: - aItem->setText(QString::number(theVal.myInt)); - break; - case ModelAPI_AttributeTables::BOOLEAN: - aItem->setText(theVal.myBool? MYTrue : MYFalse); - break; - case ModelAPI_AttributeTables::STRING: - aItem->setText(theVal.myStr.c_str()); + return QString::number(theVal.myInt); + case ModelAPI_AttributeTables::BOOLEAN: + return theVal.myBool? MYTrue : MYFalse; + case ModelAPI_AttributeTables::STRING: + return theVal.myStr.c_str(); } - return aItem; + return ""; } + //********************************************************************************** void CollectionPlugin_WidgetField::updateHeaders(QTableWidget* theDataTbl) const { @@ -398,8 +413,8 @@ QList CollectionPlugin_WidgetField::getControls() const QList aControls; // this control will accept focus and will be highlighted in the Property Panel aControls.push_back(myShapeTypeCombo); - //aControls.push_back(myFieldTypeCombo); - //aControls.push_back(myNbComponentsSpn); + aControls.push_back(myFieldTypeCombo); + aControls.push_back(myNbComponentsSpn); return aControls; } @@ -428,7 +443,7 @@ bool CollectionPlugin_WidgetField::storeValueCustom() QTableWidget* aTable = myDataTblList.first(); int aRows = aTable->rowCount(); // first column contains selected names which should not be stored - int aColumns = aTable->columnCount() - 1; + int aColumns = aTable->columnCount() - 1; aTablesAttr->setSize(aRows, aColumns, aNbSteps); aTablesAttr->setType((ModelAPI_AttributeTables::ValueType)aFldType); @@ -453,9 +468,9 @@ bool CollectionPlugin_WidgetField::restoreValueCustom() DataPtr aData = myFeature->data(); AttributeSelectionListPtr aSelList = aData->selectionList(CollectionPlugin_Field::SELECTED_ID()); - if (!aSelList->isInitialized()) - return false; std::string aTypeStr = aSelList->selectionType(); + if (aTypeStr == "") + return false; // The attribute is not initialized myShapeTypeCombo->setCurrentIndex(getSelectionType(aTypeStr)); // Get number of components @@ -476,50 +491,76 @@ bool CollectionPlugin_WidgetField::restoreValueCustom() myStepSlider->setMaximum(aNbSteps); //myStepSlider->setValue(1); // Clear old tables - myStampSpnList.clear(); - myDataTblList.clear(); - while (myStepWgt->count()) { + while (myDataTblList.count() > aNbSteps) { QWidget* aWgt = myStepWgt->widget(myStepWgt->count() - 1); myStepWgt->removeWidget(aWgt); aWgt->deleteLater(); - } - while (myStepWgt->count() < aNbSteps) + myStampSpnList.removeLast(); + myDataTblList.removeLast(); + } + while (myDataTblList.count() < aNbSteps) appendStepControls(); //myStepWgt->setCurrentIndex(myStepSlider->value() - 1); + clearData(); // Get Type of the field values + isBlocked = myFieldTypeCombo->blockSignals(true); myFieldTypeCombo->setCurrentIndex(aTablesAttr->type()); + myFieldTypeCombo->blockSignals(isBlocked); + myDelegate->setDataType(aTablesAttr->type()); AttributeIntArrayPtr aStampsAttr = aData->intArray(CollectionPlugin_Field::STAMPS_ID()); // Fill data table int aRows = aTablesAttr->rows(); int aCols = aTablesAttr->columns(); + // Get width of columns + QIntList aColWidth; + QTableWidget* aFirstTable = myDataTblList.first(); + for (int i = 0; i < aFirstTable->columnCount(); i++) + aColWidth.append(aFirstTable->columnWidth(i)); + QTableWidgetItem* aItem = 0; for (int i = 0; i < aNbSteps; i++) { myStampSpnList.at(i)->setValue(aStampsAttr->value(i)); QTableWidget* aTable = myDataTblList.at(i); isBlocked = aTable->blockSignals(true); aTable->setRowCount(aRows); + aTable->setColumnCount(aCols + 1); + updateHeaders(aTable); for (int j = 0; j < aCols + 1; j++) { for (int k = 0; k < aRows; k++) { + aItem = aTable->item(k, j); if ((j == 0) && (k > 0)) { // Add selection names AttributeSelectionPtr aAttr = aSelList->value(k - 1); - aItem = new QTableWidgetItem(aAttr->namingName().c_str()); - aTable->setItem(k, j, aItem); + if (aItem) { + aItem->setText(aAttr->namingName().c_str()); + } else { + aItem = new QTableWidgetItem(aAttr->namingName().c_str()); + aTable->setItem(k, j, aItem); + } } else if (j > 0) { // Add Values ModelAPI_AttributeTables::Value aVal = aTablesAttr->value(k, j - 1, i); - aItem = createValueItem(aVal); - if (k == 0) - aItem->setBackgroundColor(Qt::lightGray); - aTable->setItem(k, j, aItem); - + if (aItem) { + aItem->setText(getValueText(aVal)); + } else { + aItem = createValueItem(aVal); + if (k == 0) + aItem->setBackgroundColor(Qt::lightGray); + aTable->setItem(k, j, aItem); + } } } } + // Restore columns width + for (int i = 0; i < aTable->columnCount(); i++) { + if (i < aColWidth.size()) + aTable->setColumnWidth(i, aColWidth.at(i)); + } + aTable->blockSignals(isBlocked); } return true; @@ -528,17 +569,19 @@ bool CollectionPlugin_WidgetField::restoreValueCustom() //********************************************************************************** int CollectionPlugin_WidgetField::getSelectionType(const std::string& theStr) const { - if (theStr == "vertex") + QString aType(theStr.c_str()); + aType = aType.toLower(); + if (aType == "vertex") return 0; - else if (theStr == "edge") + else if (aType == "edge") return 1; - else if (theStr == "face") + else if (aType == "face") return 2; - else if (theStr == "solid") + else if (aType == "solid") return 3; - else if (theStr == "object") + else if (aType == "object") return 4; - else if (theStr == "part") + else if (aType == "part") return 5; return -1; } @@ -635,10 +678,13 @@ void CollectionPlugin_WidgetField::onNbCompChanged(int theVal) updateHeaders(aDataTbl); for (int i = aOldCol; i < myCompNamesList.count(); i++) { for (int j = 0; j < aNbRows; j++) { - aItem = createDefaultItem(); - if (j == 0) - aItem->setBackgroundColor(Qt::lightGray); - aDataTbl->setItem(j, i + 1, aItem); + aItem = aDataTbl->item(j, i + 1); + if (!aItem) { + aItem = createDefaultItem(); + if (j == 0) + aItem->setBackgroundColor(Qt::lightGray); + aDataTbl->setItem(j, i + 1, aItem); + } } } } @@ -659,7 +705,7 @@ void CollectionPlugin_WidgetField::onAddStep() aTablesAttr->setSize(aTablesAttr->rows(), aTablesAttr->columns(), myDataTblList.size()); - AttributeSelectionListPtr aSelList = + AttributeSelectionListPtr aSelList = myFeature->data()->selectionList(CollectionPlugin_Field::SELECTED_ID()); if (!aSelList->isInitialized()) return; @@ -675,21 +721,28 @@ void CollectionPlugin_WidgetField::onAddStep() for(int i = 0; i < aColumns; i++) { if (i == 0) { for(int j = 1; j < aRows; j++) { - aItem = new QTableWidgetItem(); + aItem = aTable->item(j, i); + if (!aItem) { + aItem = new QTableWidgetItem(); + aTable->setItem(j, i, aItem); + } AttributeSelectionPtr aAttr = aSelList->value(j - 1); aItem->setText(aAttr->namingName().c_str()); aItem->setToolTip(aAttr->namingName().c_str()); - aTable->setItem(j, i, aItem); } } else { QString aDefVal = aTable->item(0, i)->text(); for(int j = 1; j < aRows; j++) { - aItem = new QTableWidgetItem(); + aItem = aTable->item(j, i); + if (!aItem) { + aItem = new QTableWidgetItem(); + aTable->setItem(j, i, aItem); + } aItem->setText(aDefVal); - aTable->setItem(j, i, aItem); } } } + emit valuesChanged(); } //********************************************************************************** @@ -701,8 +754,9 @@ void CollectionPlugin_WidgetField::onRemoveStep() removeStepControls(); myStepSlider->setMaximum(aMax); - AttributeTablesPtr aTablesAttr = myFeature->data()->tables(CollectionPlugin_Field::VALUES_ID()); - aTablesAttr->setSize(aTablesAttr->rows(), aTablesAttr->columns(), myDataTblList.size()); + //AttributeTablesPtr aTablesAttr = myFeature->data()->tables(CollectionPlugin_Field::VALUES_ID()); + //aTablesAttr->setSize(aTablesAttr->rows(), aTablesAttr->columns(), myDataTblList.size()); + emit valuesChanged(); } //********************************************************************************** @@ -722,7 +776,7 @@ void CollectionPlugin_WidgetField::onStepMove(int theStep) //********************************************************************************** bool CollectionPlugin_WidgetField:: - isValidSelection(const std::shared_ptr& thePrs) + isValidSelectionCustom(const std::shared_ptr& thePrs) { return (myShapeTypeCombo->currentIndex() == 5)? false : true; } @@ -730,14 +784,20 @@ bool CollectionPlugin_WidgetField:: //********************************************************************************** void CollectionPlugin_WidgetField::onSelectionChanged() { + //if (isEditingMode()) + // return; + + if (myActivation) { + myActivation = false; + return; + } // Ignore selection for Parts mode if (myShapeTypeCombo->currentIndex() == 5) return; - QList aSelected = - myWorkshop->selection()->getSelected(ModuleBase_ISelection::AllControls); + QList aSelected = getFilteredSelected(); - AttributeSelectionListPtr aSelList = + AttributeSelectionListPtr aSelList = myFeature->data()->selectionList(CollectionPlugin_Field::SELECTED_ID()); aSelList->setSelectionType(getSelectionType(myShapeTypeCombo->currentIndex())); aSelList->clear(); @@ -764,23 +824,29 @@ void CollectionPlugin_WidgetField::onSelectionChanged() QTableWidgetItem* aItem = 0; foreach(QTableWidget* aTable, myDataTblList) { aTable->setRowCount(aNewRows); - if (aNewRows > aRows) { + if (aNewRows > aRows) { // Add new data for(int i = 0; i < aColumns; i++) { if (i == 0) { for(int j = 1; j < aNewRows; j++) { - aItem = new QTableWidgetItem(); + aItem = aTable->item(j, i); + if (!aItem) { + aItem = new QTableWidgetItem(); + aTable->setItem(j, i, aItem); + } AttributeSelectionPtr aAttr = aSelList->value(j - 1); aItem->setText(aAttr->namingName().c_str()); aItem->setToolTip(aAttr->namingName().c_str()); - aTable->setItem(j, i, aItem); } } else { QString aDefVal = aTable->item(0, i)->text(); for(int j = aRows; j < aNewRows; j++) { - aItem = new QTableWidgetItem(); + aItem = aTable->item(j, i); + if (!aItem) { + aItem = new QTableWidgetItem(); + aTable->setItem(j, i, aItem); + } aItem->setText(aDefVal); - aTable->setItem(j, i, aItem); } } } @@ -799,34 +865,30 @@ void CollectionPlugin_WidgetField::onSelectionChanged() //********************************************************************************** void CollectionPlugin_WidgetField::onFieldTypeChanged(int theIdx) { - DataTableItemDelegate* aDelegate = 0; - aDelegate = dynamic_cast(myDataTblList.first()->itemDelegate()); - if (aDelegate) { - ModelAPI_AttributeTables::ValueType aOldType = aDelegate->dataType(); - if (aOldType != theIdx) { - aDelegate->setDataType((ModelAPI_AttributeTables::ValueType)theIdx); - int aColumns = myDataTblList.first()->columnCount(); - int aRows = myDataTblList.first()->rowCount(); - foreach(QTableWidget* aTable, myDataTblList) { - for(int i = 1; i < aColumns; i++) { - for(int j = 0; j < aRows; j++) { - switch (theIdx) { - case ModelAPI_AttributeTables::DOUBLE: - case ModelAPI_AttributeTables::INTEGER: - if ((aOldType == ModelAPI_AttributeTables::BOOLEAN) || - (aOldType == ModelAPI_AttributeTables::STRING)) { - aTable->item(j, i)->setText("0"); - } - break; - case ModelAPI_AttributeTables::BOOLEAN: - aTable->item(j, i)->setText(MYFalse); - break; - } + ModelAPI_AttributeTables::ValueType aOldType = myDelegate->dataType(); + if (aOldType != theIdx) { + myDelegate->setDataType((ModelAPI_AttributeTables::ValueType)theIdx); + int aColumns = myDataTblList.first()->columnCount(); + int aRows = myDataTblList.first()->rowCount(); + foreach(QTableWidget* aTable, myDataTblList) { + for(int i = 1; i < aColumns; i++) { + for(int j = 0; j < aRows; j++) { + switch (theIdx) { + case ModelAPI_AttributeTables::DOUBLE: + case ModelAPI_AttributeTables::INTEGER: + aTable->item(j, i)->setText("0"); + break; + case ModelAPI_AttributeTables::BOOLEAN: + aTable->item(j, i)->setText(MYFalse); + break; + case ModelAPI_AttributeTables::STRING: + aTable->item(j, i)->setText(""); + break; } } } - emit valuesChanged(); } + emit valuesChanged(); } } @@ -856,7 +918,7 @@ void CollectionPlugin_WidgetField::onShapeTypeChanged(int theType) { activateSelectionAndFilters(theType == 5? false:true); - AttributeSelectionListPtr aSelList = + AttributeSelectionListPtr aSelList = myFeature->data()->selectionList(CollectionPlugin_Field::SELECTED_ID()); std::string aTypeName = getSelectionType(theType); @@ -875,8 +937,8 @@ void CollectionPlugin_WidgetField::onShapeTypeChanged(int theType) //********************************************************************************** bool CollectionPlugin_WidgetField::processEnter() { - if (myIsEditing) { - myIsEditing = false; + if (myIsTabEdit) { + myIsTabEdit = false; return true; } return false; @@ -885,8 +947,8 @@ bool CollectionPlugin_WidgetField::processEnter() //********************************************************************************** void CollectionPlugin_WidgetField::onFocusChanged(QWidget* theOld, QWidget* theNew) { - if (theNew && (!myIsEditing)) - myIsEditing = dynamic_cast(theNew); + if (theNew && (!myIsTabEdit)) + myIsTabEdit = dynamic_cast(theNew); } //********************************************************************************** @@ -896,3 +958,35 @@ void CollectionPlugin_WidgetField::onRangeChanged(int theMin, int theMax) myRemoveBtn->setEnabled(theMax > 1); } +//********************************************************************************** +void CollectionPlugin_WidgetField::onColumnResize(int theIndex, int theOld, int theNew) +{ + if (myDataTblList.count() < 2) + return; + QObject* aSender = sender(); + foreach(QTableWidget* aTable, myDataTblList) { + if (aTable->horizontalHeader() != aSender) + aTable->setColumnWidth(theIndex, theNew); + } +} + +//********************************************************************************** +QList> + CollectionPlugin_WidgetField::getAttributeSelection() const +{ + QList> aList; + if(myFeature) { + DataPtr aData = myFeature->data(); + AttributeSelectionListPtr aSelList = + aData->selectionList(CollectionPlugin_Field::SELECTED_ID()); + AttributeSelectionPtr aAttr; + ObjectPtr anObject; + for (int i = 0; i < aSelList->size(); i++) { + aAttr = aSelList->value(i); + ModuleBase_ViewerPrsPtr + aPrs(new ModuleBase_ViewerPrs(aAttr->context(), aAttr->value(), NULL)); + aList.append(aPrs); + } + } + return aList; +} \ No newline at end of file