Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerFileDialog.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Julien Finet, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 #ifndef __qSlicerFileDialog_h
22 #define __qSlicerFileDialog_h
23 
24 // Qt includes
25 #include <QObject>
26 #include <QStringList>
27 class QMimeData;
28 class QDropEvent;
29 
30 // CTK includes
31 #include <ctkPimpl.h>
32 
33 // Slicer includes
34 #include "qSlicerIO.h"
35 #include "qSlicerBaseQTGUIExport.h"
36 
38 class qSlicerIOManager;
39 //class qSlicerFileDialogPrivate;
40 class qSlicerIOOptions;
41 
42 //------------------------------------------------------------------------------
43 class Q_SLICER_BASE_QTGUI_EXPORT qSlicerFileDialog : public QObject
44 {
45  Q_OBJECT
46  Q_ENUMS(IOAction)
47  Q_PROPERTY(QString description READ description)
48 
49 public:
50  typedef QObject Superclass;
51  qSlicerFileDialog(QObject* parent =nullptr);
52  ~qSlicerFileDialog() override;
53 
54  virtual qSlicerIO::IOFileType fileType()const = 0;
55 
58  virtual QString description()const = 0;
59 
60  enum IOAction
61  {
63  Write
64  };
65  virtual qSlicerFileDialog::IOAction action()const = 0;
68  virtual bool exec(const qSlicerIO::IOProperties& ioProperties =
70 
74  static QStringList nameFilters(qSlicerIO::IOFileType fileType =
75  QString("NoFile"));
76 
81  virtual bool isMimeDataAccepted(const QMimeData*mimeData)const;
82 
88  virtual void dropEvent(QDropEvent *event);
89 
93  virtual QStringList loadedNodes()const;
94 private:
95 // Q_DECLARE_PRIVATE(qSlicerFileDialog);
96  Q_DISABLE_COPY(qSlicerFileDialog);
97 };
98 
100 
101 class qSlicerStandardFileDialogPrivate;
102 class ctkFileDialog;
103 
104 //------------------------------------------------------------------------------
105 class Q_SLICER_BASE_QTGUI_EXPORT qSlicerStandardFileDialog
106 : public qSlicerFileDialog
107 {
108  Q_OBJECT
109  Q_PROPERTY(qSlicerIO::IOFileType fileType READ fileType WRITE setFileType)
110  Q_PROPERTY(QString description READ description WRITE setDescription)
113  Q_PROPERTY(IOAction action READ action WRITE setAction)
114 
115 public:
116  qSlicerStandardFileDialog(QObject* parent=nullptr);
117  ~qSlicerStandardFileDialog() override;
118 
121  qSlicerIO::IOFileType fileType()const override;
122  virtual void setFileType(qSlicerIO::IOFileType fileType);
123 
126  QString description() const override;
127  virtual void setDescription(const QString& description);
128 
131  qSlicerFileDialog::IOAction action()const override;
134  void setAction(IOAction action);
135 
136  bool exec(const qSlicerIO::IOProperties& ioProperties =
137  qSlicerIO::IOProperties()) override;
138 
140  static QStringList getOpenFileName(qSlicerIO::IOProperties ioProperties =
141  qSlicerIO::IOProperties());
142  static QString getExistingDirectory(qSlicerIO::IOProperties ioProperties =
143  qSlicerIO::IOProperties());
144 
146  QStringList loadedNodes()const override;
147 
148 protected:
149  static ctkFileDialog* createFileDialog(const qSlicerIO::IOProperties& ioProperties =
150  qSlicerIO::IOProperties());
151 
152  qSlicerIOOptions* options(const qSlicerIO::IOProperties& ioProperties)const;
153 
154 protected:
155  QScopedPointer<qSlicerStandardFileDialogPrivate> d_ptr;
156 
157 private:
158  Q_DECLARE_PRIVATE(qSlicerStandardFileDialog);
159  Q_DISABLE_COPY(qSlicerStandardFileDialog);
160 };
161 
162 #endif
Q_DECLARE_METATYPE(QList< QVariantMap >)
Base class for qSlicerFileReader and qSlicerFileWriter.
Definition: qSlicerIO.h:41
QString IOFileType
Definition: qSlicerIO.h:52