ParaView
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:
103  enum FileMode
104  {
108  Directory
109  };
110 
117  pqFileDialog(pqServer*, QWidget* Parent, const QString& Title = QString(),
118  const QString& Directory = QString(), const QString& Filter = QString());
119  ~pqFileDialog();
120 
124  void setFileMode(FileMode);
125 
129  void setRecentlyUsedExtension(const QString& fileExtension);
130 
134  QStringList getSelectedFiles(int index = 0);
135 
139  QList<QStringList> getAllSelectedFiles();
140 
144  void accept();
145 
149  bool selectFile(const QString&);
150 
154  void setShowHidden(const bool& hidden);
155 
159  bool getShowHidden();
160 
165  static QString getSaveFileName(pqServer* server, QWidget* parentWdg,
166  const QString& title = QString(), const QString& directory = QString(),
167  const QString& filter = QString());
168 signals:
172  void filesSelected(const QList<QStringList>&);
173 
181  void filesSelected(const QStringList&);
182 
188  void fileAccepted(const QString&);
189 
190 protected:
191  bool acceptExistingFiles();
192  bool acceptDefault(const bool& checkForGrouping);
193 
194  QStringList buildFileGroup(const QString& filename);
195 
196  virtual void showEvent(QShowEvent* showEvent);
197 
198 private slots:
199  void onModelReset();
200  void onNavigate(const QString&);
201  void onNavigateUp();
202  void onNavigateBack();
203  void onNavigateForward();
204  void onNavigateDown(const QModelIndex&);
205  void onFilterChange(const QString&);
206 
207  void onClickedRecent(const QModelIndex&);
208  void onClickedFavorite(const QModelIndex&);
209  void onClickedFile(const QModelIndex&);
210 
211  void onActivateFavorite(const QModelIndex&);
212  void onActivateRecent(const QModelIndex&);
213  void onDoubleClickFile(const QModelIndex&);
214 
215  void onTextEdited(const QString&);
216 
217  void onShowHiddenFiles(const bool& hide);
218 
219  // Called when the user changes the file selection.
220  void fileSelectionChanged();
221 
222  // Called when the user right-clicks in the file qtreeview
223  void onContextMenuRequested(const QPoint& pos);
224 
225  // Called when the user requests to create a new directory in the cwd
226  void onCreateNewFolder();
227 
231  void addToFilesSelected(const QStringList&);
232 
236  void emitFilesSelectionDone();
237 
238 private:
239  pqFileDialog(const pqFileDialog&);
240  pqFileDialog& operator=(const pqFileDialog&);
241 
242  class pqImplementation;
243  pqImplementation* const Implementation;
244 
245  // returns if true if files are loaded
246  bool acceptInternal(const QStringList& selected_files, const bool& doubleclicked);
247  QString fixFileExtension(const QString& filename, const QString& filter);
248 
252  void saveState();
253 
257  void restoreState();
258 };
259 
260 #endif // !_pqFileDialog_h
FileMode
choose mode for selecting file/folder.
Definition: pqFileDialog.h:103
Provides a standard file dialog "front-end" for the pqFileDialogModel "back-end", i...
Definition: pqFileDialog.h:85
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:64