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 "pqQtDeprecated.h"
38 
39 #include <QString>
40 #include <QStringList>
41 #include <QWidget>
42 
43 class QLineEdit;
44 class pqServer;
45 
55 {
56  Q_OBJECT
57  Q_PROPERTY(QStringList filenames READ filenames WRITE setFilenames USER true)
58  Q_PROPERTY(QString singleFilename READ singleFilename WRITE setSingleFilename)
59  Q_PROPERTY(QString extension READ extension WRITE setExtension)
60  Q_PROPERTY(bool useDirectoryMode READ useDirectoryMode WRITE setUseDirectoryMode)
61  Q_PROPERTY(bool forceSingleFile READ forceSingleFile WRITE setForceSingleFile)
62  Q_PROPERTY(bool acceptAnyFile READ acceptAnyFile WRITE setAcceptAnyFile)
63 
64 public:
68  pqFileChooserWidget(QWidget* p = nullptr);
72  ~pqFileChooserWidget() override;
73 
77  QStringList filenames() const;
81  // this doesn't verify that any of the filenames being passed
82  // in are valid for the mode or actually exist on the server. That
83  // must be down be what ever calls this method
84  void setFilenames(const QStringList&);
85 
87 
91  QString singleFilename() const;
92  void setSingleFilename(const QString&);
94 
98  QString extension();
102  void setExtension(const QString&);
103 
107  bool forceSingleFile() { return this->ForceSingleFile; }
108  void setForceSingleFile(bool flag)
109  {
110  this->ForceSingleFile = flag;
111  this->setFilenames(this->filenames());
112  }
113 
117  bool useDirectoryMode() { return this->UseDirectoryMode; }
118  void setUseDirectoryMode(bool flag)
119  {
120  this->UseDirectoryMode = flag;
121  this->setFilenames(this->filenames());
122  }
123 
127  bool acceptAnyFile() { return this->AcceptAnyFile; }
128  void setAcceptAnyFile(bool flag)
129  {
130  this->AcceptAnyFile = flag;
131  this->setFilenames(this->filenames());
132  }
133 
135 
139  void setTitle(const QString& ttle) { this->Title = ttle; }
140  const QString& title() const { return this->Title; }
142 
147  void setServer(pqServer* server);
148  pqServer* server();
149 
154  static QStringList splitFilenames(const QString& filesString)
155  {
156  return filesString.split(";", PV_QT_SKIP_EMPTY_PARTS);
157  }
158  static QString joinFilenames(const QStringList& filesList) { return filesList.join(";"); }
159 
160 Q_SIGNALS:
165  void filenamesChanged(const QStringList&);
166  void filenameChanged(const QString&);
167 
168 protected Q_SLOTS:
172  void chooseFile();
176  void handleFileLineEditChanged(const QString& fileString);
177 
178 protected: // NOLINT(readability-redundant-access-specifiers)
179  QString Extension;
180  QLineEdit* LineEdit;
185  QStringList FilenameList;
187  QString Title;
188 
193  void emitFilenamesChanged(const QStringList& fileList);
194 };
195 
196 #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 PV_QT_SKIP_EMPTY_PARTS
#define const
Definition: zconf.h:238
const QString & title() const
Get/set the title to use.
bool acceptAnyFile()
flag specifying whether this widget should accept any file
input widget for files
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:63