FlightGear next
PathUrlHelper.hxx
Go to the documentation of this file.
1// PathUrlHelper.hxx - manage a stack of QML items
2//
3// Written by James Turner, started March 2018
4//
5// Copyright (C) 2018 James Turner <james@flightgear.org>
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License as
9// published by the Free Software Foundation; either version 2 of the
10// License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful, but
13// WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15// General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21#ifndef PATHURLHELPER_H
22#define PATHURLHELPER_H
23
24#include <QObject>
25#include <QUrl>
26
27class FileDialogWrapper : public QObject
28{
29 Q_OBJECT
30
31 Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
32 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
34 Q_PROPERTY(QUrl fileUrl READ fileUrl WRITE setFileUrl NOTIFY fileUrlChanged)
35 Q_PROPERTY(QString filePath READ filePath WRITE setFilePath NOTIFY fileUrlChanged)
36 Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
37public:
38 explicit FileDialogWrapper(QObject *parent = nullptr);
39
40 Q_INVOKABLE QString urlToLocalFilePath(QUrl url) const;
41
42 Q_INVOKABLE QUrl urlFromLocalFilePath(QString path) const;
43
44 Q_INVOKABLE void open();
45
46 QUrl folder() const;
47
48 QString title() const;
49
50 bool selectFolder() const;
51
52 QUrl fileUrl() const;
53
54 QString filePath() const;
55
56 QString filter() const;
57
58signals:
59
60 void accepted();
61 void rejected();
62
64
65 void titleChanged(QString title);
66
68
70
71 void filterChanged(QString filter);
72
73public slots:
74
75 void setFolder(QUrl folder);
76
77 void setTitle(QString title);
78
80
81 void setFileUrl(QUrl fileUrl);
82
83 void setFilePath(QString filePath);
84
85 void setFilter(QString filter);
86
87private:
88 QUrl m_currentFolder;
89 QUrl m_fileUrl;
90 bool m_selectFolder = false;
91 QString m_dialogTitle;
92 QString m_filter;
93};
94
95#endif // PATHURLHELPER_H
void setFolder(QUrl folder)
void fileUrlChanged(QUrl fileUrl)
void selectFolderChanged(bool selectFolder)
void setFilter(QString filter)
void setSelectFolder(bool selectFolder)
void filterChanged(QString filter)
void folderChanged(QUrl folder)
void setTitle(QString title)
void setFilePath(QString filePath)
Q_INVOKABLE void open()
FileDialogWrapper(QObject *parent=nullptr)
void titleChanged(QString title)
void setFileUrl(QUrl fileUrl)
Q_INVOKABLE QUrl urlFromLocalFilePath(QString path) const
Q_INVOKABLE QString urlToLocalFilePath(QUrl url) const