+void HYDROGUI_ColorDelegate::setModelData( QWidget* theEditor, QAbstractItemModel* theModel,
+ const QModelIndex& theIndex ) const
+{
+}
+
+QSize HYDROGUI_ColorDelegate::sizeHint( const QStyleOptionViewItem& theOption, const QModelIndex& theIndex ) const
+{
+ return theOption.rect.size();
+}
+
+
+
+
+HYDROGUI_StricklerTableDlg::HYDROGUI_StricklerTableDlg( HYDROGUI_Module* theModule, const QString& theTitle, int theType )
+: HYDROGUI_InputPanel( theModule, theTitle ),
+ myType( theType )
+{
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+
+ QString fileGroupTitle = theType == Export ? tr( "EXPORT_STRICKLER_TABLE_FILE" ) : tr( "IMPORT_STRICKLER_TABLE_FILE" );
+
+ // Import Strickler table from file
+ QGroupBox* aFileNameGroup = new QGroupBox( fileGroupTitle, this );
+ aFileNameGroup->setVisible( theType != Edit );
+
+ QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFileNameGroup );
+
+ myFileName = new QLineEdit( aFileNameGroup );
+ myFileName->setReadOnly( true );
+
+ QToolButton* aBrowseBtn = new QToolButton( aFileNameGroup );
+ aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
+
+ QBoxLayout* aFileNameLayout = new QHBoxLayout( aFileNameGroup );
+ aFileNameLayout->setMargin( 5 );
+ aFileNameLayout->setSpacing( 5 );
+ aFileNameLayout->addWidget( aFileNameLabel );
+ aFileNameLayout->addWidget( myFileName );
+ aFileNameLayout->addWidget( aBrowseBtn );
+
+ // Strickler table name
+ QGroupBox* aNameGroup = new QGroupBox( tr( "STRICKLER_TABLE_NAME" ), this );
+
+ QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), aNameGroup );
+ myName = new QLineEdit( aNameGroup );
+
+ QGroupBox* aAttrNameGroup = new QGroupBox( tr( "STRICKLER_TABLE_ATTR_NAME" ), this );
+ QLabel* aAttrNameLabel = new QLabel( tr( "ATTR_NAME" ), aAttrNameGroup );
+ myAttrName = new QLineEdit( aAttrNameGroup );
+
+ QBoxLayout* anImageNameLayout = new QHBoxLayout( aNameGroup );
+ anImageNameLayout->setMargin( 5 );
+ anImageNameLayout->setSpacing( 5 );
+ anImageNameLayout->addWidget( anImageNameLabel );
+ anImageNameLayout->addWidget( myName );
+
+ QBoxLayout* anAttrNameLayout = new QHBoxLayout( aAttrNameGroup );
+ anAttrNameLayout->setMargin( 5 );
+ anAttrNameLayout->setSpacing( 5 );
+ anAttrNameLayout->addWidget( aAttrNameLabel );
+ anAttrNameLayout->addWidget( myAttrName );
+
+ // Strickler table
+ QGroupBox* aTableGroup = new QGroupBox( tr( "STRICKLER_TABLE_TABLE" ), this );
+ aTableGroup->setVisible( theType == Edit );
+
+ // Main layout
+ QVBoxLayout* aTableLayout = new QVBoxLayout( aTableGroup );
+ aTableLayout->setMargin( 5 );
+ aTableLayout->setSpacing( 5 );
+
+ // Buttons
+ myAddBtn = new QToolButton;
+ myAddBtn->setText( tr( "ADD" ) );
+ myRemoveBtn = new QToolButton;
+ myRemoveBtn->setText( tr( "REMOVE" ) );
+ myClearBtn = new QToolButton;
+ myClearBtn->setText( tr( "CLEAR_ALL" ) );
+
+ // Table
+ myTable = new QTableWidget( mainFrame() );
+ myTable->setItemDelegateForColumn( 1, new HYDROGUI_LineEditDoubleValidator( this ) );
+ myTable->setItemDelegateForColumn( 3, new HYDROGUI_ColorDelegate( this ) );
+ myTable->setEditTriggers( QAbstractItemView::DoubleClicked |
+ QAbstractItemView::SelectedClicked |
+ QAbstractItemView::EditKeyPressed );
+
+ myTable->setColumnCount( 4 );
+ QStringList aColumnNames;
+ aColumnNames << tr( "STRICKLER_TYPE" ) << tr( "STRICKLER_COEFFICIENT" ) << tr( "ATTR_VALUE" ) << tr( "COLOR" );
+ myTable->setHorizontalHeaderLabels( aColumnNames );
+
+ myTable->horizontalHeader()->setStretchLastSection( false );
+ myTable->horizontalHeader()->setResizeMode( 0, QHeaderView::ResizeToContents );
+ myTable->horizontalHeader()->setResizeMode( 1, QHeaderView::ResizeToContents );
+ myTable->horizontalHeader()->setResizeMode( 2, QHeaderView::ResizeToContents );
+ myTable->horizontalHeader()->setResizeMode( 3, QHeaderView::Stretch );
+
+ myTable->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents );
+
+ // Layout
+ // buttons
+ QHBoxLayout* aButtonsLayout = new QHBoxLayout();
+ aButtonsLayout->addWidget( myAddBtn );
+ aButtonsLayout->addWidget( myRemoveBtn );
+ aButtonsLayout->addStretch( 1 );
+ aButtonsLayout->addWidget( myClearBtn );
+
+ // main
+ aTableLayout->addLayout( aButtonsLayout );
+ aTableLayout->addWidget( myTable );
+
+ // Common
+ addWidget( aFileNameGroup );
+ addWidget( aNameGroup );
+ addWidget( aAttrNameGroup );
+ addWidget( aTableGroup );
+
+ // Update controls
+ updateControls();
+
+ // Connections
+ connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
+ connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddCoefficient() ) );
+ connect( myRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemoveCoefficient() ) );
+ connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onClearCoefficients() ) );
+ connect( myTable->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ),
+ this, SLOT( onSelectionChanged() ) );
+
+ setMinimumWidth( 450 );
+
+ if ( theType != Edit )
+ addStretch();
+}
+