#include <QCheckBox>
HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle ), myIsEdit ( false )
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
// Import bathymetry from file
myFileNameGroup = new QGroupBox( tr( "IMPORT_BATHYMETRY_FROM_FILE" ) );
- QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
+ QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAMES" ), myFileNameGroup );
myFileNames = new QListWidget( myFileNameGroup );
+ myFileNames->setSelectionMode( QAbstractItemView::ExtendedSelection);
//myFileNames->viewport()->setAttribute( Qt::WA_TransparentForMouseEvents );
//myFileNames->setFocusPolicy(Qt::FocusPolicy::NoFocus);
QPushButton* aBrowseBtn = new QPushButton( myFileNameGroup );
- aBrowseBtn->setText("Load files(s)");
+ aBrowseBtn->setText("Add files(s)");
aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
+ QPushButton* aRemoveBtn = new QPushButton( myFileNameGroup );
+ aRemoveBtn->setText("Remove selected file(s)");
+
QBoxLayout* aFileNameLayout = new QVBoxLayout( myFileNameGroup );
myFuseIntoOne = new QCheckBox();
- myFuseIntoOne->setText("Import as one bathemetry object (fuse the geometry data)");
+ myFuseIntoOne->setText("Import as one bathymetry object (fuse the geometry data)");
myFuseIntoOne->setEnabled( false );
aFileNameLayout->setMargin( 5 );
aFileNameLayout->setSpacing( 5 );
aFileNameLayout->addWidget( aFileNameLabel );
aFileNameLayout->addWidget( aBrowseBtn );
+ aFileNameLayout->addWidget( aRemoveBtn );
aFileNameLayout->addWidget( myFileNames );
aFileNameLayout->addWidget( myFuseIntoOne );
addStretch();
connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
+ connect( aRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemove() ) );
connect( myFuseIntoOne, SIGNAL( stateChanged(int) ), this, SLOT( onStateChanged(int) ) );
}
myFuseIntoOne->setEnabled( false );
}
+void HYDROGUI_ImportBathymetryDlg::SetEditMode(bool isEdit)
+{
+ myIsEdit = isEdit;
+}
+
void HYDROGUI_ImportBathymetryDlg::setObjectName( const QString& theName )
{
myObjectName->setText( theName );
return myObjectName->text();
}
-void HYDROGUI_ImportBathymetryDlg::setFileNames( const QStringList& theFileNames )
+void HYDROGUI_ImportBathymetryDlg::addFileNames( const QStringList& theFileNames )
{
- myFileNames->clear();
- myFileNames->addItems( theFileNames );
+ //myFileNames->clear();
+ QSet<QString> exfilenames = getFileNames().toSet();
+ QStringList newFileNames;
+ foreach (QString str, theFileNames)
+ if (!exfilenames.contains(str))
+ newFileNames.append(str);
+ myFileNames->addItems( newFileNames );
+ UpdateCheckBoxStates();
+}
- if (myFuseIntoOne->isChecked() || theFileNames.count() == 1 )
+void HYDROGUI_ImportBathymetryDlg::removeFileNames( const QList<QListWidgetItem*>& theFileNamesToRem )
+{
+ foreach (QListWidgetItem* item, theFileNamesToRem)
+ delete myFileNames->takeItem(myFileNames->row(item));
+ UpdateCheckBoxStates();
+}
+
+
+void HYDROGUI_ImportBathymetryDlg::UpdateCheckBoxStates()
+{
+ if (myFuseIntoOne->isChecked() || myFileNames->count() == 1 )
{
myObjectNameGroup->setEnabled( true );
myObjectName->setEnabled( true );
myObjectName->setEnabled( false );
}
//
- if (theFileNames.count() == 1)
+ if (myFileNames->count() <= 1 || myIsEdit)
myFuseIntoOne->setEnabled( false );
- else if (theFileNames.count() > 1)
+ else
myFuseIntoOne->setEnabled( true );
+ QString anObjectName = getObjectName().simplified();
+
+ QStringList aFileNames = getFileNames();
+ if ( anObjectName.isEmpty() )
+ {
+ if (!aFileNames.empty())
+ {
+ anObjectName = aFileNames[0];
+ if ( !anObjectName.isEmpty() )
+ anObjectName = QFileInfo( anObjectName ).baseName();
+ }
+ setObjectName( anObjectName );
+ }
+
}
QStringList HYDROGUI_ImportBathymetryDlg::getFileNames() const
if( !aFileNames.isEmpty() )
{
- setFileNames( aFileNames );
+ addFileNames( aFileNames );
emit FileSelected( aFileNames );
}
}
+void HYDROGUI_ImportBathymetryDlg::onRemove()
+{
+ QList<QListWidgetItem*> selected = myFileNames->selectedItems();
+
+ removeFileNames(selected);
+}
+
void HYDROGUI_ImportBathymetryDlg::onStateChanged (int state)
{
if (getFileNames().count() > 1)