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 :
86  public QDialog
87 {
88  typedef QDialog Superclass;
89  Q_OBJECT
90 public:
91 
102  enum FileMode { AnyFile, ExistingFile, ExistingFiles, Directory };
103 
109  QWidget* Parent,
110  const QString& Title = QString(),
111  const QString& Directory = QString(),
112  const QString& Filter = QString());
113  ~pqFileDialog();
114 
116  void setFileMode(FileMode);
117 
119  void setRecentlyUsedExtension(const QString& fileExtension);
120 
122  QStringList getSelectedFiles(int index=0);
123 
125  QList<QStringList> getAllSelectedFiles();
126 
128  void accept();
129 
131  bool selectFile(const QString&);
132 
134  void setShowHidden( const bool& hidden);
135 
137  bool getShowHidden();
138 
141  static QString getSaveFileName(
142  pqServer* server, QWidget* parentWdg,
143  const QString& title = QString(),
144  const QString& directory = QString(),
145  const QString& filter = QString());
146 signals:
148  void filesSelected(const QList<QStringList> &);
149 
155  void filesSelected(const QStringList &);
156 
160  void fileAccepted(const QString&);
161 
162 protected:
163  bool acceptExistingFiles();
164  bool acceptDefault(const bool &checkForGrouping);
165 
166  QStringList buildFileGroup(const QString &filename);
167 
168  virtual void showEvent( QShowEvent *showEvent );
169 
170 private slots:
171  void onModelReset();
172  void onNavigate(const QString&);
173  void onNavigateUp();
174  void onNavigateBack();
175  void onNavigateForward();
176  void onNavigateDown(const QModelIndex&);
177  void onFilterChange(const QString&);
178 
179  void onClickedRecent(const QModelIndex&);
180  void onClickedFavorite(const QModelIndex&);
181  void onClickedFile(const QModelIndex&);
182 
183  void onActivateFavorite(const QModelIndex&);
184  void onActivateRecent(const QModelIndex&);
185  void onDoubleClickFile( const QModelIndex& );
186 
187  void onTextEdited(const QString&);
188 
189  void onShowHiddenFiles( const bool &hide );
190 
191  // Called when the user changes the file selection.
192  void fileSelectionChanged();
193 
194  // Called when the user right-clicks in the file qtreeview
195  void onContextMenuRequested(const QPoint &pos);
196 
197  // Called when the user requests to create a new directory in the cwd
198  void onCreateNewFolder();
199 
201  void addToFilesSelected(const QStringList&);
202 
204  void emitFilesSelectionDone();
205 
206 private:
207  pqFileDialog(const pqFileDialog&);
208  pqFileDialog& operator=(const pqFileDialog&);
209 
210  class pqImplementation;
211  pqImplementation* const Implementation;
212 
213  //returns if true if files are loaded
214  bool acceptInternal(const QStringList& selected_files, const bool &doubleclicked);
215  QString fixFileExtension(const QString& filename, const QString& filter);
216 
218  void saveState();
219 
221  void restoreState();
222 };
223 
224 #endif // !_pqFileDialog_h
225 
FileMode
choose mode for selecting file/folder.
Definition: pqFileDialog.h:102
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:62