pqFileChooserWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqFileChooserWidget.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 _pqFileChooserWidget_h
34 #define _pqFileChooserWidget_h
35 
36 #include "pqComponentsModule.h"
37 #include <QString>
38 #include <QStringList>
39 #include <QWidget>
40 class QLineEdit;
41 class pqServer;
42 
49 {
50  Q_OBJECT
51  Q_PROPERTY(QStringList filenames READ filenames WRITE setFilenames USER true)
52  Q_PROPERTY(QString singleFilename READ singleFilename WRITE setSingleFilename)
53  Q_PROPERTY(QString extension READ extension WRITE setExtension)
54  Q_PROPERTY(bool useDirectoryMode READ useDirectoryMode WRITE setUseDirectoryMode)
55  Q_PROPERTY(bool forceSingleFile READ forceSingleFile WRITE setForceSingleFile)
56  Q_PROPERTY(bool acceptAnyFile READ acceptAnyFile WRITE setAcceptAnyFile)
57 
58 public:
62  pqFileChooserWidget(QWidget* p = NULL);
66  ~pqFileChooserWidget() override;
67 
71  QStringList filenames() const;
75  // this doesn't verify that any of the filenames being passed
76  // in are valid for the mode or actually exist on the server. That
77  // must be down be what ever calls this method
78  void setFilenames(const QStringList&);
79 
84  QString singleFilename() const;
85  void setSingleFilename(const QString&);
86 
90  QString extension();
94  void setExtension(const QString&);
95 
99  bool forceSingleFile() { return this->ForceSingleFile; }
100  void setForceSingleFile(bool flag)
101  {
102  this->ForceSingleFile = flag;
103  this->setFilenames(this->filenames());
104  }
105 
109  bool useDirectoryMode() { return this->UseDirectoryMode; }
110  void setUseDirectoryMode(bool flag)
111  {
112  this->UseDirectoryMode = flag;
113  this->setFilenames(this->filenames());
114  }
115 
119  bool acceptAnyFile() { return this->AcceptAnyFile; }
120  void setAcceptAnyFile(bool flag)
121  {
122  this->AcceptAnyFile = flag;
123  this->setFilenames(this->filenames());
124  }
125 
127 
131  void setTitle(const QString& ttle) { this->Title = ttle; }
132  const QString& title() const { return this->Title; }
134 
139  void setServer(pqServer* server);
140  pqServer* server();
141 
146  static QStringList splitFilenames(const QString& filesString)
147  {
148  return filesString.split(";", QString::SkipEmptyParts);
149  }
150  static QString joinFilenames(const QStringList& filesList) { return filesList.join(";"); }
151 
152 Q_SIGNALS:
157  void filenamesChanged(const QStringList&);
158  void filenameChanged(const QString&);
159 
160 protected Q_SLOTS:
164  void chooseFile();
168  void handleFileLineEditChanged(const QString& fileString);
169 
170 protected:
171  QString Extension;
172  QLineEdit* LineEdit;
177  QStringList FilenameList;
179  QString Title;
180 
185  void emitFilenamesChanged(const QStringList& fileList);
186 };
187 
188 #endif // _pqFileChooserWidget_h
static QString joinFilenames(const QStringList &filesList)
#define PQCOMPONENTS_EXPORT
void setTitle(const QString &ttle)
Get/set the title to use.
void setForceSingleFile(bool flag)
bool useDirectoryMode()
flag specifying whether this widget should use directory mode
static QStringList splitFilenames(const QString &filesString)
Converts between a list of file names and delimited string of filenames (which is shown in the line e...
void setUseDirectoryMode(bool flag)
void setAcceptAnyFile(bool flag)
#define const
Definition: zconf.h:235
const QString & title() const
Get/set the title to use.
bool acceptAnyFile()
flag specifying whether this widget should accept any file
file chooser widget which consists of a tool button and a line edit hitting the tool button will brin...
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:64