CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkPathLineEdit.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 /*=========================================================================
21 
22 Program: Maverick
23 Module: $RCSfile: config.h,v $
24 
25 Copyright (c) Kitware Inc. 28 Corporate Drive,
26 Clifton Park, NY, 12065, USA.
27 
28 All rights reserved. No part of this software may be reproduced, distributed,
29 or modified, in any form or by any means, without permission in writing from
30 Kitware Inc.
31 
32 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
33 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
34 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
35 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 
37 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
38 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
39 PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
40 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
41 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
42 
43 =========================================================================*/
44 
45 #ifndef __ctkPathLineEdit_h
46 #define __ctkPathLineEdit_h
47 
48 // Qt includes
49 #include <QDir>
50 #include <QWidget>
51 class QComboBox;
52 
53 // CTK includes
54 #include "ctkWidgetsExport.h"
55 class ctkPathLineEditPrivate;
56 
61 class CTK_WIDGETS_EXPORT ctkPathLineEdit: public QWidget
62 {
63  Q_OBJECT
64  Q_FLAGS(Filters)
65  Q_PROPERTY ( QString label READ label WRITE setLabel )
66 
67  Q_PROPERTY ( Filters filters READ filters WRITE setFilters)
68  Q_PROPERTY ( QString currentPath READ currentPath WRITE setCurrentPath USER true )
72 #ifdef USE_QFILEDIALOG_OPTIONS
73  Q_PROPERTY(QFileDialog::Options options READ options WRITE setOptions)
74 #else
75  Q_PROPERTY(Options options READ options WRITE setOptions)
76  Q_FLAGS(Option Options)
77 #endif
78 
87  Q_PROPERTY(QString settingKey READ settingKey WRITE setSettingKey )
88 
89 
90  Q_PROPERTY(bool showBrowseButton READ showBrowseButton WRITE setShowBrowseButton)
94 
95 
96  Q_PROPERTY(bool showHistoryButton READ showHistoryButton WRITE setShowHistoryButton)
100 
101 
102  Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
105 
106 
107  Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
111 
112 
113  Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
116 
117 public:
118  enum Filter { Dirs = 0x001,
119  Files = 0x002,
120  Drives = 0x004,
121  NoSymLinks = 0x008,
122  AllEntries = Dirs | Files | Drives,
123  TypeMask = 0x00f,
124  Readable = 0x010,
125  Writable = 0x020,
126  Executable = 0x040,
127  PermissionMask = 0x070,
128  Modified = 0x080,
129  Hidden = 0x100,
130  System = 0x200,
131  AccessMask = 0x3F0,
132  AllDirs = 0x400,
133  CaseSensitive = 0x800,
134  NoDotAndDotDot = 0x1000, // ### Qt5 NoDotAndDotDot = NoDot|NoDotDot
135  NoDot = 0x2000,
136  NoDotDot = 0x4000,
137  NoFilter = -1
138  };
139  Q_DECLARE_FLAGS(Filters, Filter)
140 
141 #ifndef USE_QFILEDIALOG_OPTIONS
142  // Same options than QFileDialog::Options
143  enum Option
144  {
145  ShowDirsOnly = 0x00000001,
146  DontResolveSymlinks = 0x00000002,
147  DontConfirmOverwrite = 0x00000004,
148  DontUseSheet = 0x00000008,
149  DontUseNativeDialog = 0x00000010,
150  ReadOnly = 0x00000020,
151  HideNameFilterDetails = 0x00000040
152  };
153  Q_DECLARE_FLAGS(Options, Option)
154 #endif
155 
157  {
164  AdjustToMinimumContentsLength
165  };
166 
169  ctkPathLineEdit(QWidget *parent = 0);
170 
177  ctkPathLineEdit( const QString& label,
178  const QStringList& nameFilters,
179  Filters filters = ctkPathLineEdit::AllEntries,
180  QWidget *parent=0 );
181  virtual ~ctkPathLineEdit();
182  QString currentPath()const;
183 
184  void setLabel(const QString &label);
185  const QString& label()const;
186 
187  void setNameFilters(const QStringList &nameFilters);
188  const QStringList& nameFilters()const;
189 
190  void setFilters(const Filters& filters);
191  Filters filters()const;
192 
195 #ifdef USE_QFILEDIALOG_OPTIONS
196  void setOptions(const QFileDialog::Options& options);
197  const QFileDialog::Options& options()const;
198 #else
199  void setOptions(const Options& options);
200  const Options& options()const;
201 #endif
202 
205  void setCurrentFileExtension(const QString& extension);
206 
207  QString settingKey()const;
208  void setSettingKey(const QString& key);
209 
210  bool showBrowseButton()const;
211  void setShowBrowseButton(bool visible);
212 
213  bool showHistoryButton()const;
214  void setShowHistoryButton(bool visible);
215 
223 
225 
227  void setMinimumContentsLength(int lenght);
228 
230  QComboBox* comboBox() const;
231 
234  virtual QSize minimumSizeHint()const;
235 
238  virtual QSize sizeHint()const;
239 
240 Q_SIGNALS:
243  void validInputChanged(bool);
244 
245  void currentPathChanged(const QString& path);
246 
247 public Q_SLOTS:
248  void setCurrentPath(const QString& path);
249 
255  void browse();
256 
262 
267 
268 protected Q_SLOTS:
269  void setCurrentDirectory(const QString& directory);
271 
272 protected:
273  QScopedPointer<ctkPathLineEditPrivate> d_ptr;
274 
275 private:
276  Q_DECLARE_PRIVATE(ctkPathLineEdit);
277  Q_DISABLE_COPY(ctkPathLineEdit);
278 
279  Q_PRIVATE_SLOT(d_ptr, void _q_recomputeCompleterPopupSize())
280 };
281 
282 Q_DECLARE_OPERATORS_FOR_FLAGS(ctkPathLineEdit::Filters)
283 #ifndef USE_QFILEDIALOG_OPTIONS
284 Q_DECLARE_OPERATORS_FOR_FLAGS(ctkPathLineEdit::Options);
285 #endif
286 
287 #endif // __ctkPathLineEdit_h
ctkPathLineEdit::filters
Filters filters() const
ctkPathLineEdit::addCurrentPathToHistory
void addCurrentPathToHistory()
ctkPathLineEdit::setLabel
void setLabel(const QString &label)
ctkPathLineEdit::AllEntries
@ AllEntries
Definition: ctkPathLineEdit.h:122
ctkPathLineEdit::updateHasValidInput
void updateHasValidInput()
ctkPathLineEdit::Filter
Filter
Definition: ctkPathLineEdit.h:118
ctkPathLineEdit::settingKey
QString settingKey() const
Q_DECLARE_OPERATORS_FOR_FLAGS
Q_DECLARE_OPERATORS_FOR_FLAGS(ctkPathLineEdit::Options)
ctkPathLineEdit::Option
Option
Definition: ctkPathLineEdit.h:144
ctkPathLineEdit::setOptions
void setOptions(const Options &options)
ctkWrapPythonQt.options
options
Definition: ctkWrapPythonQt.py:229
ctkPathLineEdit::nameFilters
const QStringList & nameFilters() const
ctkPathLineEdit::showBrowseButton
bool showBrowseButton() const
ctkPathLineEdit::retrieveHistory
void retrieveHistory()
ctkPathLineEdit::~ctkPathLineEdit
virtual ~ctkPathLineEdit()
ctkPathLineEdit::setSizeAdjustPolicy
void setSizeAdjustPolicy(SizeAdjustPolicy policy)
ctkPathLineEdit::setFilters
void setFilters(const Filters &filters)
ctkPathLineEdit::setCurrentDirectory
void setCurrentDirectory(const QString &directory)
ctkPathLineEdit::showHistoryButton
bool showHistoryButton() const
ctkPathLineEdit::sizeHint
virtual QSize sizeHint() const
ctkPathLineEdit::setNameFilters
void setNameFilters(const QStringList &nameFilters)
ctkPathLineEdit::ctkPathLineEdit
ctkPathLineEdit(QWidget *parent=0)
ctkPathLineEdit::minimumSizeHint
virtual QSize minimumSizeHint() const
ctkPathLineEdit::comboBox
QComboBox * comboBox() const
Return the combo box internally used by the path line edit.
ctkPathLineEdit::browse
void browse()
ctkPathLineEdit::minimumContentsLength
int minimumContentsLength() const
ctkPathLineEdit::d_ptr
QScopedPointer< ctkPathLineEditPrivate > d_ptr
Definition: ctkPathLineEdit.h:273
ctkPathLineEdit::setSettingKey
void setSettingKey(const QString &key)
ctkPathLineEdit::sizeAdjustPolicy
SizeAdjustPolicy sizeAdjustPolicy() const
ctkPathLineEdit::validInputChanged
void validInputChanged(bool)
ctkPathLineEdit::setShowHistoryButton
void setShowHistoryButton(bool visible)
ctkPathLineEdit::setCurrentFileExtension
void setCurrentFileExtension(const QString &extension)
ctkPathLineEdit::AdjustToContents
@ AdjustToContents
The path line edit will always adjust to the contents.
Definition: ctkPathLineEdit.h:159
ctkPathLineEdit::setShowBrowseButton
void setShowBrowseButton(bool visible)
ctkPathLineEdit::currentPath
QString currentPath() const
ctkPathLineEdit::AdjustToContentsOnFirstShow
@ AdjustToContentsOnFirstShow
The path line edit will adjust to its contents the first time it is shown.
Definition: ctkPathLineEdit.h:161
ctkPathLineEdit::ctkPathLineEdit
ctkPathLineEdit(const QString &label, const QStringList &nameFilters, Filters filters=ctkPathLineEdit::AllEntries, QWidget *parent=0)
ctkPathLineEdit::options
const Options & options() const
ctkPathLineEdit::label
const QString & label() const
ctkPathLineEdit::setMinimumContentsLength
void setMinimumContentsLength(int lenght)
ctkPathLineEdit::currentPathChanged
void currentPathChanged(const QString &path)
ctkPathLineEdit
Advanced line edit to select a file or directory.
Definition: ctkPathLineEdit.h:62
ctkPathLineEdit::SizeAdjustPolicy
SizeAdjustPolicy
Definition: ctkPathLineEdit.h:157
ctkPathLineEdit::setCurrentPath
void setCurrentPath(const QString &path)