myFileName = new QLineEdit( myFileNameGroup );
myFileName->setReadOnly( true );
- QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
- aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
+ myBrowseBtn = new QToolButton( myFileNameGroup );
+ myBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
aFileNameLayout->setMargin( 5 );
aFileNameLayout->setSpacing( 5 );
aFileNameLayout->addWidget( aFileNameLabel );
aFileNameLayout->addWidget( myFileName );
- aFileNameLayout->addWidget( aBrowseBtn );
+ aFileNameLayout->addWidget( myBrowseBtn );
// Image name
myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ), this );
addWidget( myTransformGroup );
addStretch();
- connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
+ connect( myBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
connect( myModeGroup, SIGNAL( buttonClicked( int ) ),
this, SLOT( onModeActivated( int ) ) );
void HYDROGUI_ImportImageDlg::onBrowse()
{
QString aFilter( tr( "IMAGE_FILTER" ) );
- QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true );
- if( !aFileName.isEmpty() )
+ QStringList aFileNamesList = SUIT_FileDlg::getOpenFileNames( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true );
+ emit filesSelected( aFileNamesList );
+}
+
+void HYDROGUI_ImportImageDlg::ActivateFile( const QString& theFileName, bool isEnableFilesChoice )
+{
+ myFileName->setEnabled( isEnableFilesChoice );
+ myBrowseBtn->setEnabled( isEnableFilesChoice );
+
+ if( !theFileName.isEmpty() )
{
- QImage anImage( aFileName );
+ QImage anImage( theFileName );
if( anImage.isNull() )
{
QString aTitle = QObject::tr( "INPUT_VALID_DATA" );
QString aMessage = QObject::tr( "FILE_CAN_NOT_BE_IMPORTED" ).
- arg( aFileName ).arg( QFileInfo( aFileName ).suffix() );
+ arg( theFileName ).arg( QFileInfo( theFileName ).suffix() );
SUIT_MessageBox::warning( module()->getApp()->desktop(), aTitle, aMessage );
}
else
{
- setFileName( aFileName );
+ setFileName( theFileName );
+ setImageName( "" );
emit createPreview( anImage );
}
}
class QtxDoubleSpinBox;
class QtxIntSpinBox;
class QAbstractSpinBox;
+class QToolButton;
class HYDROGUI_ImportImageDlg : public HYDROGUI_InputPanel
{
void initializePointSelection();
+ void ActivateFile( const QString& theFileName, bool isEnableFilesChoice );
+
public:
static TransformationData ComputeTrsfData( const int theMode,
void modeActivated( int );
void refImageActivated( const QString& );
void setCIsUsed( bool theIsByTwoPoints );
+ void filesSelected( const QStringList& );
private:
QGroupBox* myFileNameGroup; //!< The group for the source image file selection
QLineEdit* myFileName; //!< Source image file name input field
+ QToolButton* myBrowseBtn;
QGroupBox* myImageNameGroup; //!< The group for the image name input field
QLineEdit* myImageName; //!< The image name input field
connect( aPanel, SIGNAL( refImageActivated( const QString& ) ),
SLOT( onRefImageActivated( const QString& ) ) );
connect( aPanel, SIGNAL( setCIsUsed( bool ) ), SLOT( onSetCIsUsed( bool ) ) );
+ connect( aPanel, SIGNAL( filesSelected( const QStringList& ) ),
+ SLOT( onFilesSelected( const QStringList& ) ) );
return aPanel;
}
anImageObj->Update();
theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced;
+
+ if( SetNextFile() )
+ {
+ theErrorMsg = "";
+ commitDocOperation(); // to save the modifications in the data model
+ return false; // and to continue the operation
+ }
+
return true;
}
aViewMgr = 0;
}
}
+
+void HYDROGUI_ImportImageOp::onFilesSelected( const QStringList& theFileNames )
+{
+ myFiles = theFileNames;
+ myFileIndex = -1;
+ SetNextFile();
+}
+
+bool HYDROGUI_ImportImageOp::SetNextFile()
+{
+ myFileIndex++;
+ bool isEnabledEdit = myFiles.count()==1 || myFileIndex==myFiles.count();
+ bool isValid = ( myFileIndex>=0 && myFileIndex<myFiles.count() );
+ QString aFile = isValid ? myFiles[myFileIndex] : "";
+
+ HYDROGUI_ImportImageDlg* aPanel = dynamic_cast<HYDROGUI_ImportImageDlg*>( inputPanel() );
+ aPanel->ActivateFile( aFile, isEnabledEdit );
+ return isValid;
+}