Debian Codegraph @

src/common/adapter/fileDialog/FileDialogAdapter.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 Damir Porobic <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "FileDialogAdapter.h"
21
22 QString FileDialogAdapter::getExistingDirectory(QWidget *parent, const QString &title, const QString &directory)
23 {
24
25 return QFileDialog::getExistingDirectory(parent, title, directory, QFileDialog::ShowDirsOnly | mOptions);
26 }
27
28 QString FileDialogAdapter::getOpenFileName(QWidget *parent, const QString &title, const QString &directory)
29 {
30 return QFileDialog::getOpenFileName(parent, title, directory, nullptr, nullptr, mOptions);
31 }
32
33 QStringList FileDialogAdapter::getOpenFileNames(QWidget *parent, const QString &title, const QString &directory, const QString &filter)
34 {
35 return QFileDialog::getOpenFileNames(parent, title, directory, filter, nullptr, mOptions);
36 }
37
38 QString FileDialogAdapter::getSavePath(QWidget *parent, const QString &title, const QString &path, const QString &filter)
39 {
40 QFileDialog saveDialog(parent, title, path, filter);
41 saveDialog.setAcceptMode(QFileDialog::AcceptSave);
42 saveDialog.setOptions(mOptions);
43
44 if (saveDialog.exec() == QDialog::Accepted) {
45 return saveDialog.selectedFiles().first();
46 }
47
48 return {};
49 }
50
51 void FileDialogAdapter::addOption(QFileDialog::Option option)
52 {
53 mOptions |= option;
54 }