Salome HOME
Merge from BR_Dev_For_4_0 branch (from tag mergeto_BR_QT4_Dev_07Jul08)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.cxx
index e3a58cdff882ebdcf35a112455e13dc7ccf15484..7a12b1522513b79a55d1ed46ca6e13f44c6cee24 100755 (executable)
@@ -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<int>& theTypes)
 
     // layout widgets
     QGridLayout* aLay = new QGridLayout(myTableGrp);
-    aLay->setMargin(0);
+    aLay->setMargin(MARGIN);
     aLay->setSpacing(SPACING);
 
     aLay->addWidget(mySwitchTableGrp, 0, 0, 7, 1);
@@ -1004,9 +1024,9 @@ void SMESHGUI_FilterTable::GetCriterion (const int                 theRow,
   }
   else
   {
-    theCriterion.ThresholdStr = CORBA::string_dup( aTable->text(theRow, 2).toLatin1().constData() );
+    theCriterion.ThresholdStr = aTable->text(theRow, 2).toLatin1().constData();
     if ( aCriterionType != SMESH::FT_RangeOfIds )
-      theCriterion.ThresholdID = CORBA::string_dup( aTable->text( theRow, 5 ).toLatin1().constData() );
+      theCriterion.ThresholdID = aTable->text( theRow, 5 ).toLatin1().constData();
   }
 
   QTableWidgetItem* anItem = aTable->item(theRow, 0);
@@ -1391,6 +1411,8 @@ void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const boo
   // Logical operation AND / OR
   theTable->setItem(aCurrRow, 4, new QTableWidgetItem());
 
+  theTable->setItem(aCurrRow, 5, new QTableWidgetItem());
+    
   theTable->blockSignals( isSignalsBlocked );
 
   // Logical binary operation for previous value
@@ -1625,7 +1647,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);
@@ -2375,7 +2397,7 @@ bool SMESHGUI_FilterDlg::isValid() const
       myTable->GetThreshold(i, aName);
 
       std::vector<_PTR(SObject)> aList =
-        SMESH::GetActiveStudyDocument()->FindObjectByName(aName.toLatin1().data(), "GEOM");
+        SMESH::GetActiveStudyDocument()->FindObjectByName(aName.toLatin1().constData(), "GEOM");
       if (aList.size() == 0) {
         SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                     tr("BAD_SHAPE_NAME").arg(aName));