FlightGear next
StackController.hxx
Go to the documentation of this file.
1// StackController.hxx - manage a stack of QML items
2//
3// Written by James Turner, started February 2019
4//
5// Copyright (C) 2019 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
22#ifndef FG_GUI_STACK_CONTROLLER_HXX
23#define FG_GUI_STACK_CONTROLLER_HXX
24
25#include <QObject>
26#include <QUrl>
27#include <QVector>
28
29class StackController : public QObject
30{
31 Q_OBJECT
32
34
35 Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY currentPageChanged)
36
39
40public:
42
43 Q_INVOKABLE void push(QUrl page, QString title);
44 Q_INVOKABLE void pop();
45 Q_INVOKABLE void replace(QUrl url, QString title);
46
47 QUrl currentPageSource() const;
48
49 bool canGoBack() const;
50 QString currentPageTitle() const;
51 QString previousPageTitle() const;
52
53signals:
55
56private:
57 QVector<QUrl> m_stack;
58 QVector<QString> m_titles;
59};
60
61#endif // FG_GUI_STACK_CONTROLLER_HXX
Q_INVOKABLE void replace(QUrl url, QString title)
Q_INVOKABLE void pop()
Q_INVOKABLE void push(QUrl page, QString title)
void currentPageChanged()