FlightGear
next
StackController.cxx
Go to the documentation of this file.
1
// StackController.cxx - 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
#include "
StackController.hxx
"
22
23
StackController::StackController
()
24
{
25
}
26
27
QUrl
StackController::currentPageSource
()
const
28
{
29
if
(m_stack.empty())
30
return
{};
31
return
m_stack.front();
32
}
33
34
QString
StackController::currentPageTitle
()
const
35
{
36
if
(m_stack.empty())
37
return
{};
38
return
m_titles.front();
39
}
40
41
QString
StackController::previousPageTitle
()
const
42
{
43
if
(m_titles.size() < 2)
44
return
{};
45
return
m_titles.at(1);
46
}
47
48
bool
StackController::canGoBack
()
const
49
{
50
return
(m_stack.size() > 1);
51
}
52
53
void
StackController::push
(QUrl page, QString title)
54
{
55
m_stack.push_front(page);
56
m_titles.push_front(title);
57
emit
currentPageChanged
();
58
}
59
60
void
StackController::pop
()
61
{
62
if
(m_stack.empty())
63
return
;
64
m_stack.pop_front();
65
m_titles.pop_front();
66
emit
currentPageChanged
();
67
}
68
69
void
StackController::replace
(QUrl url, QString title)
70
{
71
m_stack.clear();
72
m_stack.push_back(url);
73
m_titles.clear();
74
m_titles.push_back(title);
75
76
emit
currentPageChanged
();
77
}
StackController.hxx
StackController::StackController
StackController()
Definition
StackController.cxx:23
StackController::canGoBack
bool canGoBack
Definition
StackController.hxx:35
StackController::replace
Q_INVOKABLE void replace(QUrl url, QString title)
Definition
StackController.cxx:69
StackController::pop
Q_INVOKABLE void pop()
Definition
StackController.cxx:60
StackController::previousPageTitle
QString previousPageTitle
Definition
StackController.hxx:38
StackController::currentPageTitle
QString currentPageTitle
Definition
StackController.hxx:37
StackController::push
Q_INVOKABLE void push(QUrl page, QString title)
Definition
StackController.cxx:53
StackController::currentPageSource
QUrl currentPageSource
Definition
StackController.hxx:33
StackController::currentPageChanged
void currentPageChanged()
src
GUI
StackController.cxx
Generated on Tue Jun 3 2025 12:58:39 for FlightGear by
1.13.2