itom
Loading...
Searching...
No Matches
pathLineEdit.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom and its software development toolkit (SDK).
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 In addition, as a special exception, the Institut für Technische
15 Optik (ITO) gives you certain additional rights.
16 These rights are described in the ITO LGPL Exception version 1.0,
17 which can be found in the file LGPL_EXCEPTION.txt in this package.
18
19 itom is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22 General Public Licence for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with itom. If not, see <http://www.gnu.org/licenses/>.
26
27 This file is a port and modified version of the
28 CTK Common Toolkit (http://www.commontk.org)
29*********************************************************************** */
30/*=========================================================================
31
32Program: Maverick
33Module: $RCSfile: config.h,v $
34
35Copyright (c) Kitware Inc. 28 Corporate Drive,
36Clifton Park, NY, 12065, USA.
37
38All rights reserved. No part of this software may be reproduced, distributed,
39or modified, in any form or by any means, without permission in writing from
40Kitware Inc.
41
42IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
43DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
44OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
45EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
47THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
48BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
49PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
50"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
51MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
52
53=========================================================================*/
54
55#ifndef PATHLINEEDIT_H
56#define PATHLINEEDIT_H
57
58// Qt includes
59#include <QDir>
60#include <QWidget>
61class QComboBox;
62
63// CTK includes
64#include "commonWidgets.h"
66
71class ITOMWIDGETS_EXPORT PathLineEdit: public QWidget
72{
73 Q_OBJECT
74
75 Q_FLAGS(Filters)
76 Q_PROPERTY ( QString label READ label WRITE setLabel )
77
78 Q_PROPERTY ( Filters filters READ filters WRITE setFilters)
79 Q_PROPERTY ( QString currentPath READ currentPath WRITE setCurrentPath USER true )
83#ifdef USE_QFILEDIALOG_OPTIONS
84 Q_PROPERTY(QFileDialog::Options options READ options WRITE setOptions)
85#else
86 Q_PROPERTY(Options options READ options WRITE setOptions)
87 Q_FLAGS(Option Options)
88#endif
89
98 Q_PROPERTY(QString settingKey READ settingKey WRITE setSettingKey )
99
100
104 Q_PROPERTY(bool showBrowseButton READ showBrowseButton WRITE setShowBrowseButton)
105
110 Q_PROPERTY(bool showHistoryButton READ showHistoryButton WRITE setShowHistoryButton)
111
115 Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
116
121 Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
122
126 Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
127
128public:
129 enum Filter { Dirs = 0x001,
130 Files = 0x002,
131 Drives = 0x004,
132 NoSymLinks = 0x008,
133 AllEntries = Dirs | Files | Drives,
134 TypeMask = 0x00f,
135 Readable = 0x010,
136 Writable = 0x020,
137 Executable = 0x040,
138 PermissionMask = 0x070,
139 Modified = 0x080,
140 Hidden = 0x100,
141 System = 0x200,
142 AccessMask = 0x3F0,
143 AllDirs = 0x400,
144 CaseSensitive = 0x800,
145 NoDotAndDotDot = 0x1000, // ### Qt5 NoDotAndDotDot = NoDot|NoDotDot
146 NoDot = 0x2000,
147 NoDotDot = 0x4000,
148 NoFilter = -1
149 };
150 Q_DECLARE_FLAGS(Filters, Filter)
151
152#ifndef USE_QFILEDIALOG_OPTIONS
153 // Same options than QFileDialog::Options
154 enum Option
155 {
156 ShowDirsOnly = 0x00000001,
157 DontResolveSymlinks = 0x00000002,
158 DontConfirmOverwrite = 0x00000004,
159 DontUseSheet = 0x00000008,
160 DontUseNativeDialog = 0x00000010,
161 ReadOnly = 0x00000020,
162 HideNameFilterDetails = 0x00000040
163 };
164 Q_DECLARE_FLAGS(Options, Option)
165#endif
166
168 {
175 AdjustToMinimumContentsLength
176 };
177
178 //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration
179 //values are always accessible.
180 Q_ENUM(SizeAdjustPolicy);
181
184 PathLineEdit(QWidget *parent = 0);
185
192 PathLineEdit( const QString& label,
193 const QStringList& nameFilters,
194 Filters filters = PathLineEdit::AllEntries,
195 QWidget *parent=0 );
196 virtual ~PathLineEdit();
197 QString currentPath()const;
198
199 void setLabel(const QString &label);
200 const QString& label()const;
201
202 void setNameFilters(const QStringList &nameFilters);
203 const QStringList& nameFilters()const;
204
205 void setFilters(const Filters& filters);
206 Filters filters()const;
207
210#ifdef USE_QFILEDIALOG_OPTIONS
211 void setOptions(const QFileDialog::Options& options);
212 const QFileDialog::Options& options()const;
213#else
214 void setOptions(const Options& options);
215 const Options& options()const;
216#endif
217
220 void setCurrentFileExtension(const QString& extension);
221
222 QString settingKey()const;
223 void setSettingKey(const QString& key);
224
225 bool showBrowseButton()const;
226 void setShowBrowseButton(bool visible);
227
228 bool showHistoryButton()const;
229 void setShowHistoryButton(bool visible);
230
237 SizeAdjustPolicy sizeAdjustPolicy() const;
238
239 void setSizeAdjustPolicy(SizeAdjustPolicy policy);
240
241 int minimumContentsLength()const;
242 void setMinimumContentsLength(int length);
243
245 QComboBox* comboBox() const;
246
249 virtual QSize minimumSizeHint()const;
250
253 virtual QSize sizeHint()const;
254
255signals:
259
260 void currentPathChanged(const QString& path);
261
262public slots:
263 void setCurrentPath(const QString& path);
264
270 void browse();
271
276 void retrieveHistory();
277
281 void addCurrentPathToHistory();
282
283protected Q_SLOTS:
284 void setCurrentDirectory(const QString& directory);
285 void updateHasValidInput();
286
287protected:
288 QScopedPointer<PathLineEditPrivate> d_ptr;
289
290private:
291 Q_DECLARE_PRIVATE(PathLineEdit);
292 Q_DISABLE_COPY(PathLineEdit);
293
294 Q_PRIVATE_SLOT(d_ptr, void _q_recomputeCompleterPopupSize())
295};
296
297Q_DECLARE_OPERATORS_FOR_FLAGS(PathLineEdit::Filters)
298#ifndef USE_QFILEDIALOG_OPTIONS
299Q_DECLARE_OPERATORS_FOR_FLAGS(PathLineEdit::Options);
300#endif
301
302#endif // PATHLINEEDIT_H
Advanced line edit to select a file or directory.
Definition pathLineEdit.h:72
SizeAdjustPolicy
Definition pathLineEdit.h:168
@ AdjustToContents
The path line edit will always adjust to the contents.
Definition pathLineEdit.h:170
@ AdjustToContentsOnFirstShow
The path line edit will adjust to its contents the first time it is shown.
Definition pathLineEdit.h:172
void validInputChanged(bool)
Definition pathLineEdit.cpp:51