CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Loading...
Searching...
No Matches
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
22Program: Maverick
23Module: $RCSfile: config.h,v $
24
25Copyright (c) Kitware Inc. 28 Corporate Drive,
26Clifton Park, NY, 12065, USA.
27
28All rights reserved. No part of this software may be reproduced, distributed,
29or modified, in any form or by any means, without permission in writing from
30Kitware Inc.
31
32IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
33DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
34OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
35EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
37THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
38BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
39PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
40"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
41MAINTENANCE, 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>
51class QComboBox;
52
53// CTK includes
54#include "ctkWidgetsExport.h"
55class ctkPathLineEditPrivate;
56
61class 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
93 Q_PROPERTY(bool showBrowseButton READ showBrowseButton WRITE setShowBrowseButton)
94
95
99 Q_PROPERTY(bool showHistoryButton READ showHistoryButton WRITE setShowHistoryButton)
100
101
104 Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
105
106
110 Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
111
112
115 Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
116
117public:
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
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 );
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
240Q_SIGNALS:
244
245 void currentPathChanged(const QString& path);
246
247public Q_SLOTS:
248 void setCurrentPath(const QString& path);
249
255 void browse();
256
262
267
268protected Q_SLOTS:
269 void setCurrentDirectory(const QString& directory);
271
272protected:
273 QScopedPointer<ctkPathLineEditPrivate> d_ptr;
274
275private:
276 Q_DECLARE_PRIVATE(ctkPathLineEdit);
277 Q_DISABLE_COPY(ctkPathLineEdit);
278
279 Q_PRIVATE_SLOT(d_ptr, void _q_recomputeCompleterPopupSize())
280};
281
282Q_DECLARE_OPERATORS_FOR_FLAGS(ctkPathLineEdit::Filters)
283#ifndef USE_QFILEDIALOG_OPTIONS
284Q_DECLARE_OPERATORS_FOR_FLAGS(ctkPathLineEdit::Options);
285#endif
286
287#endif // __ctkPathLineEdit_h
Advanced line edit to select a file or directory.
void setCurrentFileExtension(const QString &extension)
void setLabel(const QString &label)
void validInputChanged(bool)
ctkPathLineEdit(QWidget *parent=0)
QString settingKey() const
bool showBrowseButton() const
const Options & options() const
void updateHasValidInput()
virtual QSize sizeHint() const
Filters filters() const
void setShowHistoryButton(bool visible)
void setMinimumContentsLength(int lenght)
@ AdjustToContentsOnFirstShow
The path line edit will adjust to its contents the first time it is shown.
@ AdjustToContents
The path line edit will always adjust to the contents.
void setCurrentDirectory(const QString &directory)
void setNameFilters(const QStringList &nameFilters)
QString currentPath() const
void setSettingKey(const QString &key)
void setOptions(const Options &options)
virtual QSize minimumSizeHint() const
QComboBox * comboBox() const
Return the combo box internally used by the path line edit.
void retrieveHistory()
virtual ~ctkPathLineEdit()
const QStringList & nameFilters() const
void currentPathChanged(const QString &path)
void setSizeAdjustPolicy(SizeAdjustPolicy policy)
void setCurrentPath(const QString &path)
ctkPathLineEdit(const QString &label, const QStringList &nameFilters, Filters filters=ctkPathLineEdit::AllEntries, QWidget *parent=0)
void setShowBrowseButton(bool visible)
SizeAdjustPolicy sizeAdjustPolicy() const
void addCurrentPathToHistory()
const QString & label() const
bool showHistoryButton() const
void setFilters(const Filters &filters)
QScopedPointer< ctkPathLineEditPrivate > d_ptr
int minimumContentsLength() const
Q_DECLARE_OPERATORS_FOR_FLAGS(ctkPathLineEdit::Options)