OTB  6.7.0
Orfeo Toolbox
otbQtFileSelectionWidget.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbQtFileSelectionWidget_h
22 #define otbQtFileSelectionWidget_h
23 
24 #include <QtWidgets>
28 
29 #include "OTBQtWidgetExport.h"
30 #include <string>
31 
32 namespace otb
33 {
34 namespace Wrapper
35 {
36 
42 class OTBQtWidget_EXPORT QtFileSelectionWidget : public QWidget
43 {
44  Q_OBJECT
45 public:
46  enum IOMode
47  {
48  IO_MODE_INPUT = 0,
49  IO_MODE_OUTPUT = 1,
50  };
51 
53  ~QtFileSelectionWidget() override;
54 
55  bool IsChecked()
56  {
57  return m_Checkbox->isChecked();
58  }
59 
60  void SetChecked( bool val )
61  {
62  return m_Checkbox->setChecked( val );
63  }
64 
65  std::string GetFilename()
66  {
67  return QFile::encodeName( m_Input->text() ).constData();
68  }
69 
71  {
72  m_Input->clear();
73  }
74 
75  QLineEdit* GetInput()
76  {
77  return m_Input;
78  }
79 
80  void SetIOMode( IOMode );
81  IOMode GetIOMode() const;
82 
83 signals:
84  void FilenameChanged();
85 
86 protected slots:
87  void SelectFile();
88  void CallFilenameChanged();
89  void SetFileName(const QString &);
90 
91 private:
93  void operator=(const QtFileSelectionWidget&) = delete;
94 
95  virtual void DoCreateWidget();
96 
97  virtual void DoUpdateGUI();
98 
99 
100  QHBoxLayout * m_HLayout;
101  QLineEdit * m_Input;
102  QPushButton * m_Button;
103  QCheckBox * m_Checkbox;
105 };
106 
107 
108 }
109 }
110 
111 #endif