annotate src/filenamerequester.cpp @ 87:cc0ce6d26c9f

Added tag 1.3 for changeset 08cca723e37d
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 05 Oct 2016 15:01:26 +0200
parents a43d8cf2fa95
children
rev   line source
50
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2016 by ETH Zürich
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
3 *
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
6 * See LICENSE.txt for details.
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
7 */
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 /* This file was originally taken from Libkleo where the license was:
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 ui/filenamerequester.cpp
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 This file is part of Kleopatra, the KDE keymanager
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13 Copyright (c) 2007 Klarälvdalens Datakonsult AB
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15 Kleopatra is free software; you can redistribute it and/or modify
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16 it under the terms of the GNU General Public License as published by
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17 the Free Software Foundation; either version 2 of the License, or
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
18 (at your option) any later version.
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
19
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
20 Kleopatra is distributed in the hope that it will be useful,
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
23 General Public License for more details.
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25 You should have received a copy of the GNU General Public License
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
26 along with this program; if not, write to the Free Software
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29 In addition, as a special exception, the copyright holders give
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
30 permission to link the code of this program with any edition of
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31 the Qt library by Trolltech AS, Norway (or with modified versions
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
32 of Qt that use the same license as Qt), and distribute linked
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 combinations including the two. You must obey the GNU General
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34 Public License in all respects for all of the code used other than
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
35 Qt. If you modify this file, you may extend this exception to
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 your version of the file, but you are not obligated to do so. If
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
37 you do not wish to do so, delete this exception statement from
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
38 your version.
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
39 */
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
40
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
41 #include "filenamerequester.h"
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
42
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
43 #include <QLineEdit>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
44
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
45 #include <QHBoxLayout>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
46 #include <QToolButton>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
47 #include <QCompleter>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
48 #include <QDirModel>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
49 #include <QString>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
50 #include <QFileDialog>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
51 #include <QApplication>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
52 #include <QStyle>
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
53
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
54 class FileNameRequester::Private
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
55 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
56 friend class FileNameRequester;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
57 FileNameRequester *const q;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
58 public:
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
59 explicit Private(FileNameRequester *qq);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
60 ~Private();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
61
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
62 private:
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
63 void slotButtonClicked();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
64
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
65 private:
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
66 QDirModel dirmodel;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
67 QCompleter completer;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
68
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
69 QLineEdit lineedit;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
70 QToolButton button;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
71 QHBoxLayout hlay;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
72
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
73 QString nameFilter;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
74 bool existingOnly;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
75 };
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
76
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
77 FileNameRequester::Private::Private(FileNameRequester *qq)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
78 : q(qq),
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
79 dirmodel(),
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
80 completer(&dirmodel),
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
81 lineedit(q),
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
82 button(q),
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
83 hlay(q),
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
84 nameFilter(),
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
85 existingOnly(true)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
86 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
87 button.setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
88 lineedit.setCompleter(&completer);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
89 lineedit.setClearButtonEnabled(true);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
90 hlay.setMargin(0);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
91 hlay.addWidget(&lineedit);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
92 hlay.addWidget(&button);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
93
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
94 connect(&button, SIGNAL(clicked()), q, SLOT(slotButtonClicked()));
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
95 connect(&lineedit, &QLineEdit::textChanged, q, &FileNameRequester::fileNameChanged);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
96 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
97
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
98 FileNameRequester::Private::~Private() {}
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
99
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
100 FileNameRequester::FileNameRequester(QWidget *p)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
101 : QWidget(p), d(new Private(this))
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
102 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
103
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
104 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
105
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
106 FileNameRequester::FileNameRequester(QDir::Filters f, QWidget *p)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
107 : QWidget(p), d(new Private(this))
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
108 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
109 d->dirmodel.setFilter(f);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
110 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
111
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
112 FileNameRequester::~FileNameRequester()
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
113 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
114 delete d;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
115 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
116
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
117 void FileNameRequester::setFileName(const QString &file)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
118 {
53
a43d8cf2fa95 Various fixes and improvements. Fix windows packaging.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
119 const QString converted = QDir::toNativeSeparators(file);
a43d8cf2fa95 Various fixes and improvements. Fix windows packaging.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
120 d->lineedit.setText(converted);
50
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
121 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
122
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
123 QString FileNameRequester::fileName() const
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
124 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
125 return d->lineedit.text();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
126 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
127
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
128 void FileNameRequester::setExistingOnly(bool on)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
129 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
130 d->existingOnly = on;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
131 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
132
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
133 bool FileNameRequester::existingOnly() const
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
134 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
135 return d->existingOnly;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
136 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
137
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
138 void FileNameRequester::setFilter(QDir::Filters f)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
139 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
140 d->dirmodel.setFilter(f);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
141 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
142
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
143 QDir::Filters FileNameRequester::filter() const
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
144 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
145 return d->dirmodel.filter();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
146 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
147
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
148 void FileNameRequester::setNameFilter(const QString &nameFilter)
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
149 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
150 d->nameFilter = nameFilter;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
151 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
152
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
153 QString FileNameRequester::nameFilter() const
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
154 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
155 return d->nameFilter;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
156 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
157
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
158 void FileNameRequester::Private::slotButtonClicked()
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
159 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
160 const QString fileName = q->requestFileName();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
161 if (!fileName.isEmpty()) {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
162 q->setFileName(fileName);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
163 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
164 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
165
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
166 QString FileNameRequester::requestFileName()
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
167 {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
168 const QDir::Filters filters = filter();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
169 if ((filters & QDir::Dirs) && !(filters & QDir::Files)) {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
170 return QFileDialog::getExistingDirectory(this);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
171 } else if (d->existingOnly) {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
172 return QFileDialog::getOpenFileName(this, QString(), QString(), d->nameFilter);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
173 } else {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
174 return QFileDialog::getSaveFileName(this, QString(), QString(), d->nameFilter);
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
175 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
176 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
177
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
178 #include "moc_filenamerequester.cpp"
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)