X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_StreamDlg.cxx;h=95f0750bda8f08194e944d5882ba655a72347a68;hb=541470db80142c32e3812a7b79e26727df1dcece;hp=cc8ba0f8ec3ac368fab96e1ce35363f9d4d86150;hpb=7293e4989b4e85a3531cd6c77b14e5129ee617aa;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx index cc8ba0f8..95f0750b 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,8 +18,16 @@ #include "HYDROGUI_StreamDlg.h" +#include "HYDROGUI_ListSelector.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_OrderedListWidget.h" #include "HYDROGUI_Tool.h" +#include + +#include +#include + #include #include #include @@ -49,18 +53,18 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin // Stream parameters QGroupBox* aParamGroup = new QGroupBox( tr( "STREAM_PARAMETERS" ), mainFrame() ); - myAxises = new QComboBox( aParamGroup ); - myAxises->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myAxes = new QComboBox( aParamGroup ); + myAxes->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); QBoxLayout* anAxisLayout = new QHBoxLayout(); anAxisLayout->addWidget( new QLabel( tr( "STREAM_HYDRAULIC_AXIS" ) ) ); - anAxisLayout->addWidget( myAxises ); - - myProfiles = new QListWidget( aParamGroup ); - myProfiles->setSelectionMode( QListWidget::MultiSelection ); - myProfiles->setEditTriggers( QListWidget::NoEditTriggers ); - myProfiles->setViewMode( QListWidget::ListMode ); - myProfiles->setSortingEnabled( false ); + anAxisLayout->addWidget( myAxes ); + myProfiles = new HYDROGUI_OrderedListWidget( aParamGroup, 0 ); + myProfiles->setHiddenObjectsShown(true); + myProfiles->setVisibilityIconShown(false); + myProfiles->setContentsMargins(QMargins()); + myProfiles->setOrderingEnabled( false ); + myAddButton = new QPushButton( aParamGroup ); myAddButton->setText( tr("ADD") ); myRemoveButton = new QPushButton( aParamGroup ); @@ -84,8 +88,15 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin addWidget( aParamGroup ); addStretch(); + // Create selector + if ( module() ) { + HYDROGUI_ListSelector* aListSelector = + new HYDROGUI_ListSelector( myProfiles, module()->getApp()->selectionMgr() ); + aListSelector->setAutoBlock( true ); + } + // Connect signals and slots - connect( myAxises, SIGNAL( currentIndexChanged( const QString & ) ), + connect( myAxes, SIGNAL( currentIndexChanged( const QString & ) ), this, SIGNAL( AxisChanged( const QString& ) ) ); connect( myAddButton, SIGNAL( clicked() ), this, SIGNAL( AddProfiles() ) ); connect( myRemoveButton, SIGNAL( clicked() ), this, SLOT( onRemoveProfiles() ) ); @@ -101,13 +112,12 @@ void HYDROGUI_StreamDlg::reset() myObjectName->clear(); - myAxises->clear(); - myProfiles->clear(); + myAxes->clear(); + myProfiles->setObjects( HYDROGUI_ListModel::Object2VisibleList() ); myAddButton->setEnabled( false ); + myRemoveButton->setEnabled( false ); blockSignals( isBlocked ); - - onStreamDefChanged(); } void HYDROGUI_StreamDlg::setObjectName( const QString& theName ) @@ -124,91 +134,57 @@ void HYDROGUI_StreamDlg::setAxisNames( const QStringList& theAxises ) { bool isBlocked = blockSignals( true ); - myAxises->clear(); - myAxises->addItems( theAxises ); + myAxes->clear(); + myAxes->addItems( theAxises ); blockSignals( isBlocked ); } void HYDROGUI_StreamDlg::setAxisName( const QString& theName ) { - myAddButton->setEnabled( !myAxises->currentText().isEmpty() ); + bool isBlocked = blockSignals( true ); - int aNewIdx = myAxises->findText( theName ); - if ( aNewIdx != myAxises->currentIndex() ) - { - myAxises->setCurrentIndex( aNewIdx ); - } - else - { - onStreamDefChanged(); + int aNewId = myAxes->findText( theName ); + if ( aNewId != myAxes->currentIndex() ) { + myAxes->setCurrentIndex( aNewId ); } + myAddButton->setEnabled( myAxes->currentIndex() > -1 ); + + blockSignals( isBlocked ); } QString HYDROGUI_StreamDlg::getAxisName() const { - return myAxises->currentText(); + return myAxes->currentText(); } -void HYDROGUI_StreamDlg::setSelectedProfiles( const QStringList& theProfiles ) +void HYDROGUI_StreamDlg::setProfiles( const QStringList& theProfiles ) { bool isBlocked = blockSignals( true ); myProfiles->setUpdatesEnabled( false ); - myProfiles->clear(); - for ( int i = 0, n = theProfiles.length(); i < n; ++i ) - { - const QString& aProfileName = theProfiles.at( i ); - QListWidgetItem* aListItem = new QListWidgetItem( aProfileName, myProfiles ); - aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); + HYDROGUI_ListModel::Object2VisibleList aProfiles; + foreach ( const QString& aProfileName, theProfiles ) { + Handle(HYDROData_Profile) anObject = Handle(HYDROData_Profile)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aProfileName ) ); + if ( !anObject.IsNull() ) { + aProfiles.append( HYDROGUI_ListModel::Object2Visible( anObject, true ) ); + } } - myProfiles->setUpdatesEnabled( true ); - - blockSignals( isBlocked ); - - onStreamDefChanged(); -} - -QStringList HYDROGUI_StreamDlg::getSelectedProfiles() const -{ - QStringList aProfiles; - - for ( int i = 0, n = myProfiles->count(); i < n; ++i ) - { - QListWidgetItem* aListItem = myProfiles->item( i ); - if ( !aListItem ) - continue; - - QString aProfileName = aListItem->text(); - aProfiles << aProfileName; - } + myProfiles->setObjects( aProfiles ); - return aProfiles; -} + myRemoveButton->setEnabled( myProfiles->getObjects().count() > 0 ); -void HYDROGUI_StreamDlg::onStreamDefChanged() -{ - if ( signalsBlocked() ) - return; + myProfiles->setUpdatesEnabled( true ); - emit CreatePreview(); + blockSignals( isBlocked ); } void HYDROGUI_StreamDlg::onRemoveProfiles() { - QStringList aSelectedProfiles; + QStringList aSelectedProfiles = myProfiles->getSelectedNames(); - QList aSelectedItems = myProfiles->selectedItems(); - foreach( const QListWidgetItem* anItem, aSelectedItems ) { - QString aProfileName = anItem->text(); - if ( !aProfileName.isEmpty() ) { - aSelectedProfiles << aProfileName; - } - } - - if ( !aSelectedProfiles.isEmpty() ) { - emit RemoveProfiles( aSelectedProfiles ); - } + emit RemoveProfiles( aSelectedProfiles ); }