+
+ QStringList aTypes = theTable->GetTypes();
+ myTable->setRowCount( 0 );
+ foreach( QString aType, aTypes )
+ {
+ // Check the current Strickler type
+ if( aType.isEmpty() )
+ continue;
+
+ // Get Strickler data for the current Strickler type
+ QString aCoefficient = HYDROGUI_Tool::GetCoordinateString( theTable->Get( aType, 0.0 ), false );
+ QString anAttrValue = theTable->GetAttrValue( aType );
+ QColor aColor = theTable->GetColor( aType );
+
+ // Insert row with the data
+ int aRow = myTable->rowCount();
+ myTable->insertRow( aRow );
+
+ // "Type" column
+ QTableWidgetItem* aTypeItem = new QTableWidgetItem( aType );
+ myTable->setItem( aRow, 0, aTypeItem );
+
+ // "Coefficient" column
+ myTable->setItem( aRow, 1, new QTableWidgetItem( aCoefficient ) );
+
+ // "Attribute value" column
+ myTable->setItem( aRow, 2, new QTableWidgetItem( anAttrValue ) );
+
+ // "Color" column
+ QTableWidgetItem* anItem = new QTableWidgetItem();
+ anItem->setBackgroundColor( aColor );
+ myTable->setItem( aRow, 3, anItem );
+ }
+
+ myTable->resizeColumnToContents( 0 );
+ myTable->resizeRowsToContents();
+
+ updateControls();
+}
+
+void HYDROGUI_StricklerTableDlg::updateControls()
+{
+ bool isTableNotEmpty = myTable->rowCount() > 0;
+ myClearBtn->setEnabled( isTableNotEmpty );
+ onSelectionChanged();
+}
+
+void HYDROGUI_StricklerTableDlg::removeRows( const QList<int> theRows )
+{
+ QList<int> aSortedRows = theRows;
+ qSort( aSortedRows );
+
+ int aRowToRemove = -1;
+ int aNbRemoved = 0;
+ foreach ( int aRow, aSortedRows ) {
+ aRowToRemove = aRow - aNbRemoved;
+ if ( myTable->model()->removeRow( aRowToRemove ) ) {
+ aNbRemoved++;
+ }
+ }
+
+ if ( aNbRemoved > 0 )
+ updateControls();
+}
+
+void HYDROGUI_StricklerTableDlg::onBrowse()
+{
+ QString aFilter( tr( "STRICKLER_TABLE_FILTER" ) );
+ QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, myFileName->parent()->property( "title" ).toString(), myType == Import );
+ if ( !aFileName.isEmpty() )
+ {
+ setFileName( aFileName );
+ emit fileSelected( aFileName );
+ }
+}
+
+/**
+Add the new default constructed Strickler coefficient.
+*/
+void HYDROGUI_StricklerTableDlg::onAddCoefficient()
+{
+ int aRow = myTable->rowCount();
+ myTable->insertRow( aRow );
+
+ for( int i=0; i<COLUMNS_COUNT; i++ )
+ {
+ myTable->setItem( aRow, i, new QTableWidgetItem() );
+ }
+
+ // Set default type (=> generate unique type name) and coefficient
+ //...
+
+ updateControls();
+}
+
+/**
+Remove the selected Strickler coefficient.
+*/
+void HYDROGUI_StricklerTableDlg::onRemoveCoefficient()
+{
+ QList<int> aRows;
+ QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedIndexes();
+ foreach ( const QModelIndex& anIndex, aSelectedIndexes ) {
+ int aRowIndex = anIndex.row();
+ if ( !aRows.contains( aRowIndex ) )
+ aRows << aRowIndex;
+ }
+
+ removeRows( aRows );
+}
+
+/**
+Clear all Strickler coefficients.
+*/
+void HYDROGUI_StricklerTableDlg::onClearCoefficients()
+{
+ QList<int> aRows;
+ for ( int i=0; i< myTable->rowCount(); i++ ) {
+ aRows << i;
+ }
+
+ removeRows( aRows );
+}
+
+/**
+Slot called on table selection change.
+*/
+void HYDROGUI_StricklerTableDlg::onSelectionChanged()
+{
+ QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedIndexes();
+ myRemoveBtn->setEnabled( aSelectedIndexes.count() > 0 );