X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_FilterDlg.cxx;h=9491e8de64338edea27c4cd113cebd5f1592371f;hb=62c4337c5becb0add8bff676b465f70cc5f4e513;hp=a8ec5525e78fe9ebd81d86208b2f4f8ff16742f4;hpb=17397a8eee9d07dd1a403296632338e96cde2867;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index a8ec5525e..9491e8de6 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -1,29 +1,29 @@ -// SMESH SMESHGUI : GUI for SMESH component +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// 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. +// 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. // -// 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_FilterDlg.cxx // Author : Sergey LITONIN, Open CASCADE S.A.S. -// - // SMESH includes +// #include "SMESHGUI_FilterDlg.h" #include "SMESHGUI.h" @@ -501,6 +501,8 @@ public: Table( int, int, QWidget* = 0 ); virtual ~Table(); + QSize minimumSizeHint() const; + void setEditable( bool, int, int ); bool isEditable( int, int ) const; @@ -526,6 +528,10 @@ SMESHGUI_FilterTable::Table::Table (QWidget* parent) setReadOnly( false ); } +//======================================================================= +// name : SMESHGUI_FilterTable::Table::Table +// Purpose : Constructor +//======================================================================= SMESHGUI_FilterTable::Table::Table (int numRows, int numCols, QWidget* parent) : QTableWidget(numRows, numCols, parent) { @@ -535,10 +541,27 @@ SMESHGUI_FilterTable::Table::Table (int numRows, int numCols, QWidget* parent) setReadOnly( false ); } +//======================================================================= +// name : SMESHGUI_FilterTable::Table::~Table +// Purpose : Destructor +//======================================================================= SMESHGUI_FilterTable::Table::~Table() { } +//======================================================================= +// name : SMESHGUI_FilterTable::Table::minimumSizeHint +// Purpose : Get minimum size for the table +//======================================================================= +QSize SMESHGUI_FilterTable::Table::minimumSizeHint() const +{ + QSize s = QTableWidget::minimumSizeHint(); + QHeaderView* hv = horizontalHeader(); + if ( hv ) + s.setWidth( qMax( s.width(), hv->length() ) ); + return s; +} + //======================================================================= // name : SMESHGUI_FilterTable::Table::setEditable // Purpose : Set editable of specified cell @@ -574,15 +597,12 @@ void SMESHGUI_FilterTable::Table::setReadOnly( bool on ) { setEditTriggers( on ? QAbstractItemView::NoEditTriggers : - QAbstractItemView::DoubleClicked | - QAbstractItemView::SelectedClicked | - QAbstractItemView::EditKeyPressed | - QAbstractItemView::AnyKeyPressed ); + QAbstractItemView::AllEditTriggers ); } bool SMESHGUI_FilterTable::Table::isReadOnly() const { - return editTriggers() != QAbstractItemView::NoEditTriggers; + return editTriggers() == QAbstractItemView::NoEditTriggers; } //======================================================================= @@ -733,7 +753,7 @@ void SMESHGUI_FilterTable::Init (const QList& theTypes) // layout widgets QGridLayout* aLay = new QGridLayout(myTableGrp); - aLay->setMargin(0); + aLay->setMargin(MARGIN); aLay->setSpacing(SPACING); aLay->addWidget(mySwitchTableGrp, 0, 0, 7, 1); @@ -1288,6 +1308,7 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con if (aCompareItem->count() > 0) aCompareItem->clear(); + aTable->setEditable(false, row, 1); aTable->setEditable(false, row, 2); aTable->blockSignals( isSignalsBlocked ); @@ -1302,6 +1323,8 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con QMap aMap; aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO"); aCompareItem->setItems(aMap); + if (!aTable->isEditable(row, 2)) + aTable->setEditable(true, row, 1); if (!aTable->isEditable(row, 2)) aTable->setEditable(true, row, 2); } @@ -1316,6 +1339,8 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con bool isOk = false; aText.toDouble(&isOk); aTable->item( row, 2 )->setText(isOk ? aText : QString("")); + if (!aTable->isEditable(row, 1)) + aTable->setEditable(true, row, 1); if (!aTable->isEditable(row, 2)) aTable->setEditable(true, row, 2); } @@ -1627,7 +1652,7 @@ SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable (QWidget* thePar aHeaderLabels.append( tr("BINARY") + " " ); aHeaderLabels.append( tr("ID") ); aTable->setHorizontalHeaderLabels( aHeaderLabels ); - + // set geometry of the table for (int i = 0; i <= 4; i++) aTable->resizeColumnToContents(i); @@ -1671,6 +1696,21 @@ void SMESHGUI_FilterTable::SetEditable (const bool isEditable) { anIter.value()->setReadOnly(!isEditable); + // Set Flags for CheckItems directly IPAL 19974 + Table* aTable = anIter.value(); + for (int i = 0, n = aTable->rowCount(); i < n; i++) + for (int j = 0, m = aTable->columnCount(); j < m; j++) + { + QTableWidgetItem* anItem = aTable->item(i, j); + if ( dynamic_cast( anItem ) ) { + Qt::ItemFlags f = anItem->flags(); + if (!isEditable) f = f & ~Qt::ItemIsUserCheckable; + else f = f | Qt::ItemIsUserCheckable; + anItem->setFlags( f ); + } + } + //end of IPAL19974 + if (isEditable) { myAddBtn->show(); @@ -2042,11 +2082,11 @@ QWidget* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent) aLay->setMargin(MARGIN); aLay->setSpacing(SPACING); - myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_OK" ), aGrp); - myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp); - myButtons[ BTN_Cancel ] = new QPushButton(tr("SMESH_BUT_CANCEL"), aGrp); - myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp); - myButtons[ BTN_Help ] = new QPushButton(tr("SMESH_BUT_HELP"), aGrp); + myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGrp); + myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp); + myButtons[ BTN_Cancel ] = new QPushButton(tr("SMESH_BUT_CANCEL"), aGrp); + myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp); + myButtons[ BTN_Help ] = new QPushButton(tr("SMESH_BUT_HELP"), aGrp); aLay->addWidget(myButtons[ BTN_OK ]); aLay->addSpacing(10); @@ -2440,9 +2480,13 @@ void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg) // name : SMESHGUI_FilterDlg::SetGroupIds // Purpose : Set mesh //======================================================================= -void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_ptr theMesh) +void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_var theMesh) { myMesh = theMesh; + if ( myMesh->_is_nil() ) { + myButtons[BTN_OK]->setEnabled(false); + myButtons[BTN_Apply]->setEnabled(false); + } } //======================================================================= @@ -2777,6 +2821,14 @@ void SMESHGUI_FilterDlg::onSelectionDone() int aRow, aCol; const SALOME_ListIO& aList = mySelector->StoredIObjects(); + if ( myMesh->_is_nil() && aList.Extent()>0 ) { + myMesh = SMESH::IObjectToInterface(aList.First()); + if ( !(myMesh->_is_nil()) ) { + myButtons[BTN_OK]->setEnabled(true); + myButtons[BTN_Apply]->setEnabled(true); + } + } + if (aList.Extent() != 1 || !myTable->CurrentCell(aRow, aCol) || myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGeom && @@ -2796,6 +2848,7 @@ void SMESHGUI_FilterDlg::onSelectionDone() } } + //======================================================================= // name : SMESHGUI_FilterDlg::onCriterionChanged // Purpose : SLOT called when cretarion of current row changed. Update selection