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
ctkDirectoryButton.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#ifndef __ctkDirectoryButton_h
22#define __ctkDirectoryButton_h
23
24// Qt includes
25#include <QDir>
26#include <QFileDialog>
27#include <QIcon>
28
29// CTK includes
30#include <ctkPimpl.h>
31#include "ctkWidgetsExport.h"
32class ctkDirectoryButtonPrivate;
33
34// QFileDialog::Options can be used since Qt 4.7.0 (QT_VERSION >= 0x040700)
35// it is disabled to support older Qt versions
36//#define USE_QFILEDIALOG_OPTIONS 1
37
43class CTK_WIDGETS_EXPORT ctkDirectoryButton: public QWidget
44{
45 Q_OBJECT
53 Q_PROPERTY(QFileDialog::AcceptMode acceptMode READ acceptMode WRITE setAcceptMode)
54 Q_PROPERTY(QString directory READ directory WRITE setDirectory NOTIFY directoryChanged USER true)
57 Q_PROPERTY(QString caption READ caption WRITE setCaption)
60 Q_PROPERTY(QString text READ text WRITE setText)
63 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
67#ifdef USE_QFILEDIALOG_OPTIONS
68 Q_PROPERTY(QFileDialog::Options options READ options WRITE setOptions)
69#else
70 Q_PROPERTY(Options options READ options WRITE setOptions)
71 Q_FLAGS(Option Options);
72#endif
73
74public:
75#ifndef USE_QFILEDIALOG_OPTIONS
76 // Same options than QFileDialog::Options
77 enum Option
78 {
79 ShowDirsOnly = 0x00000001,
80 DontResolveSymlinks = 0x00000002,
81 DontConfirmOverwrite = 0x00000004,
82 DontUseSheet = 0x00000008,
83 DontUseNativeDialog = 0x00000010,
84 ReadOnly = 0x00000020,
85 HideNameFilterDetails = 0x00000040
86 };
87 Q_DECLARE_FLAGS(Options, Option)
88#endif
89
93 ctkDirectoryButton(QWidget * parent = 0);
96 ctkDirectoryButton(const QString& directory, QWidget * parent = 0);
97 ctkDirectoryButton(const QIcon& icon, const QString& directory, QWidget * parent = 0);
98
101
105 void setDirectory(const QString& path);
106 QString directory()const;
107
110 void setCaption(const QString& caption);
113 const QString& caption()const;
114
118 void setText(const QString& text);
121 const QString& text()const;
122
126 void setIcon(const QIcon& icon);
127 QIcon icon()const;
128
131#ifdef USE_QFILEDIALOG_OPTIONS
132 void setOptions(const QFileDialog::Options& options);
133 const QFileDialog::Options& options()const;
134#else
135 void setOptions(const Options& options);
136 const Options& options()const;
137#endif
138
140 QFileDialog::AcceptMode acceptMode() const;
141
143 void setAcceptMode(QFileDialog::AcceptMode mode);
144
145public Q_SLOTS:
148 void browse();
149
150Q_SIGNALS:
155 void directoryChanged(const QString&);
156
162 void directorySelected(const QString&);
163
164protected:
165 QScopedPointer<ctkDirectoryButtonPrivate> d_ptr;
166
167private:
168 Q_DECLARE_PRIVATE(ctkDirectoryButton);
169 Q_DISABLE_COPY(ctkDirectoryButton);
170};
171
172#ifndef USE_QFILEDIALOG_OPTIONS
173Q_DECLARE_OPERATORS_FOR_FLAGS(ctkDirectoryButton::Options);
174#endif
175
176#endif
void setCaption(const QString &caption)
void setAcceptMode(QFileDialog::AcceptMode mode)
void setText(const QString &text)
ctkDirectoryButton(QWidget *parent=0)
QFileDialog::AcceptMode acceptMode() const
QString directory() const
void setIcon(const QIcon &icon)
QScopedPointer< ctkDirectoryButtonPrivate > d_ptr
void directorySelected(const QString &)
const QString & text() const
virtual ~ctkDirectoryButton()
Destructor.
ctkDirectoryButton(const QIcon &icon, const QString &directory, QWidget *parent=0)
const QString & caption() const
ctkDirectoryButton(const QString &directory, QWidget *parent=0)
void directoryChanged(const QString &)
void setOptions(const Options &options)
const Options & options() const
void setDirectory(const QString &path)
QIcon icon() const
Q_DECLARE_OPERATORS_FOR_FLAGS(ctkDirectoryButton::Options)