pqFileDialog.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqFileDialog.h
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 =========================================================================*/
32 
33 #ifndef _pqFileDialog_h
34 #define _pqFileDialog_h
35 
36 #include "pqCoreModule.h"
37 #include <QDialog>
38 #include <QStringList>
39 
40 class QModelIndex;
41 class QPoint;
42 class pqServer;
43 class QShowEvent;
44 
85 class PQCORE_EXPORT pqFileDialog : public QDialog
86 {
87  typedef QDialog Superclass;
88  Q_OBJECT
89 public:
109  enum FileMode
110  {
115  ExistingFilesAndDirectories
116  };
117 
124  pqFileDialog(pqServer* server, QWidget* parent, const QString& title = QString(),
125  const QString& directory = QString(), const QString& filter = QString());
126  ~pqFileDialog() override;
127 
131  void setFileMode(FileMode);
132 
136  void setRecentlyUsedExtension(const QString& fileExtension);
137 
141  QStringList getSelectedFiles(int index = 0);
142 
146  QList<QStringList> getAllSelectedFiles();
147 
151  void accept() override;
152 
156  bool selectFile(const QString&);
157 
161  void setShowHidden(const bool& hidden);
162 
166  bool getShowHidden();
167 
172  static QString getSaveFileName(pqServer* server, QWidget* parentWdg,
173  const QString& title = QString(), const QString& directory = QString(),
174  const QString& filter = QString());
175 Q_SIGNALS:
179  void filesSelected(const QList<QStringList>&);
180 
188  void filesSelected(const QStringList&);
189 
195  void fileAccepted(const QString&);
196 
197 protected:
198  bool acceptExistingFiles();
199  bool acceptDefault(const bool& checkForGrouping);
200 
201  QStringList buildFileGroup(const QString& filename);
202 
203  void showEvent(QShowEvent* showEvent) override;
204 
205 private Q_SLOTS:
206  void onModelReset();
207  void onNavigate(const QString& = QString());
208  void onNavigateUp();
209  void onNavigateBack();
210  void onNavigateForward();
211  void onNavigateDown(const QModelIndex&);
212  void onFilterChange(const QString&);
213 
214  void onClickedRecent(const QModelIndex&);
215  void onClickedFavorite(const QModelIndex&);
216  void onClickedFile(const QModelIndex&);
217 
218  void onActivateFavorite(const QModelIndex&);
219  void onActivateRecent(const QModelIndex&);
220  void onDoubleClickFile(const QModelIndex&);
221 
222  void onTextEdited(const QString&);
223 
224  void onShowHiddenFiles(const bool& hide);
225 
226  void onShowDetailToggled(bool show);
227 
228  // Called when the user changes the file selection.
229  void fileSelectionChanged();
230 
231  // Called when the user right-clicks in the file qtreeview
232  void onContextMenuRequested(const QPoint& pos);
233 
234  // Called when the user requests to create a new directory in the cwd
235  void onCreateNewFolder();
236 
240  void addToFilesSelected(const QStringList&);
241 
245  void emitFilesSelectionDone();
246 
252  void updateButtonStates();
253 
254 private:
255  pqFileDialog(const pqFileDialog&);
256  pqFileDialog& operator=(const pqFileDialog&);
257 
258  class pqImplementation;
259  pqImplementation* const Implementation;
260 
261  // returns if true if files are loaded
262  bool acceptInternal(const QStringList& selected_files);
263  QString fixFileExtension(const QString& filename, const QString& filter);
264 
268  void saveState();
269 
273  void restoreState();
274 };
275 
276 #endif // !_pqFileDialog_h
FileMode
choose mode for selecting file/folder.
Definition: pqFileDialog.h:109
Provides a standard file dialog "front-end" for the pqFileDialogModel "back-end", i...
Definition: pqFileDialog.h:85
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:64