Salome HOME
58c65216e56313febfaf351e8078836fc5100eb9
[modules/geom.git] / src / STEPPlugin / STEPPlugin_ImportDlg.cxx
1 // Copyright (C) 2014-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "STEPPlugin_ImportDlg.h"
21
22 #include <QApplication>
23 #include <QLayout>
24 #include <QCheckBox>
25
26 //=============================================================================
27 // Constructor
28 //=============================================================================
29 STEPPlugin_ImportDlg::STEPPlugin_ImportDlg(QWidget *parent)
30   : SUIT_FileDlg (parent, true, true, true),
31     myCheckBox   (0)
32 {
33   myCheckBox = new QCheckBox(tr("STEP_CREATE_ASSEMBLIES"), this);
34
35   myCheckBox->setChecked(true);
36
37   layout()->addWidget(myCheckBox);
38 }
39
40 //=============================================================================
41 // Destructor
42 //=============================================================================
43 STEPPlugin_ImportDlg::~STEPPlugin_ImportDlg()
44 {
45 }
46
47 //=============================================================================
48 // IsCreateAssemblies
49 //=============================================================================
50 bool STEPPlugin_ImportDlg::IsCreateAssemblies() const
51 {
52   return myCheckBox->isChecked();
53 }
54
55 //=============================================================================
56 // getOpenFileNames
57 //=============================================================================
58 QStringList STEPPlugin_ImportDlg::getOpenFileNames
59                                   (const QString &theInitial,
60                                    const QString &theFilters,
61                                    const QString &theCaption,
62                                          QWidget *theParent,
63                                          bool    &IsCreateAssemblies)
64 {
65   STEPPlugin_ImportDlg anImpDlg(theParent);
66   QStringList aFilters = theFilters.split(";;", QString::SkipEmptyParts);
67
68   anImpDlg.setFileMode(ExistingFiles);
69
70   if (aFilters.isEmpty()) {
71     anImpDlg.setNameFilter(tr("ALL_FILES_FILTER")); // All files (*)
72   } else {
73     anImpDlg.setNameFilters(aFilters);
74   }
75
76   if (!theCaption.isEmpty()) {
77     anImpDlg.setWindowTitle(theCaption);
78   }
79
80   if (!theInitial.isEmpty()) {
81     anImpDlg.processPath(theInitial);
82   }
83
84   QStringList aFileNames;
85
86   if (anImpDlg.exec() == QDialog::Accepted) {
87     aFileNames = anImpDlg.selectedFiles();
88     IsCreateAssemblies = anImpDlg.IsCreateAssemblies();
89   }
90
91   QApplication::processEvents();
92
93   return aFileNames;
94 }