PageRouter
#include <pagerouter.h>

Properties | |
int | cacheCapacity |
QJSValue | initialRoute |
ColumnView | pageStack |
QQmlPropertyMap | params |
int | preloadedPoolCapacity |
QQmlListProperty< PageRoute > | routes |
![]() | |
objectName | |
Signals | |
void | currentIndexChanged () |
void | initialRouteChanged () |
void | navigationChanged () |
void | pageStackChanged () |
void | routesChanged () |
Public Member Functions | |
PageRouter (QQuickItem *parent=nullptr) | |
Q_INVOKABLE void | bringToView (QJSValue route) |
int | cacheCapacity () const |
Q_INVOKABLE QJSValue | currentRoutes () const |
QJSValue | initialRoute () const |
Q_INVOKABLE void | navigateToRoute (QJSValue route) |
QQmlPropertyMap * | params () |
Q_INVOKABLE void | popRoute () |
int | preloadedPoolCapacity () const |
Q_INVOKABLE void | pushRoute (QJSValue route) |
Q_INVOKABLE bool | routeActive (QJSValue route) |
QQmlListProperty< PageRoute > | routes () |
void | setCacheCapacity (int size) |
void | setInitialRoute (QJSValue initialRoute) |
void | setPreloadedPoolCapacity (int size) |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
Static Public Member Functions | |
static PageRouterAttached * | qmlAttachedProperties (QObject *object) |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions | |
void | classBegin () override |
void | componentComplete () override |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
![]() | |
typedef | QObjectList |
Detailed Description
An item managing pages and data of a ColumnView using named routes.
Using a PageRouter
Applications typically manage their contents via elements called "pages" or "screens." In Kirigami, these are called Pages and are arranged in routes using a PageRouter to manage them. The PageRouter manages a stack of Pages created from a pool of potential PageRoutes .
Unlike most traditional stacks, a PageRouter provides functions for random access to its pages with navigateToRoute and routeActive.
When your user interface fits the stack paradigm and is likely to use random access navigation, using the PageRouter is appropriate. For simpler navigation, it is more appropriate to avoid the overhead of a PageRouter by using a PageRow instead.
Navigation Model
A PageRouter draws from a pool of PageRoutes in order to construct its stack.
You can push pages onto this stack...
...or pop them off...
...or navigate to an arbitrary collection of pages.
Components are able to query the PageRouter about the currently active routes on the stack. This is useful for e.g. a card indicating that the page it takes the user to is currently active.
Example
- See also
- PageRouterAttached
- PageRoute
Definition at line 333 of file pagerouter.h.
Property Documentation
◆ cacheCapacity
|
readwrite |
How large the cache can be.
The combined costs of cached routes will never exceed the cache capacity.
Definition at line 379 of file pagerouter.h.
◆ initialRoute
|
readwrite |
The initial route.
initialRoute
is the page that the PageRouter will push upon creation. Changing it after creation will cause the PageRouter to reset its state. Not providing an initialRoute
will result in undefined behavior.
- See also
- org::kde::kirigami::PageRoute::name import QtQuick 2.12import org.kde.kirigami 2.12 as KirigamiKirigami.ApplicationWindow {id: rootKirigami.PageRouter {initialRoute: "home"pageStack: root.pageStack.columnViewKirigami.PageRoute {name: "home"Kirigami.Page {// This page will show up when starting the application}}}Kirigami.PageRoute {name: "login"Kirigami.Page {// Page contents...}}}}}
Definition at line 358 of file pagerouter.h.
◆ pageStack
ColumnView PageRouter::pageStack |
The ColumnView being puppeted by the PageRouter.
All PageRouters should be created with a ColumnView, and creating one without a ColumnView is undefined behaviour.
- Warning
- You should not directly interact with a ColumnView being puppeted by a PageRouter. Instead, use a PageRouter's functions to manipulate the ColumnView.
Definition at line 372 of file pagerouter.h.
◆ params
|
read |
Exposes the data of all pages on the stack, preferring pages on the top (e.g.
most recently pushed) to pages pushed on the bottom (least recently pushed).
Definition at line 393 of file pagerouter.h.
◆ preloadedPoolCapacity
|
readwrite |
How large the preloaded pool can be.
The combined costs of preloaded routes will never exceed the pool capacity.
Definition at line 386 of file pagerouter.h.
◆ routes
|
read |
The named routes a PageRouter can navigate to.
Definition at line 343 of file pagerouter.h.
Member Function Documentation
◆ bringToView()
void PageRouter::bringToView | ( | QJSValue | route | ) |
Shifts keyboard focus and view to a given index on the PageRouter's stack.
- Parameters
-
view The view to bring to focus. If this is an integer index, the PageRouter will navigate to the given index. If it's a route specifier, the PageRouter will navigate to the first route matching it.
Navigating to route by index:
Navigating to route by name:
Navigating to route by data:
Definition at line 323 of file pagerouter.cpp.
◆ currentRoutes()
QJSValue PageRouter::currentRoutes | ( | ) | const |
Returns a QJSValue corresponding to the current pages on the stack.
The returned value is in the same form as the input to navigateToRoute.
Definition at line 751 of file pagerouter.cpp.
◆ navigateToRoute()
void PageRouter::navigateToRoute | ( | QJSValue | route | ) |
Navigate to the given route.
Calling navigateToRoute
causes the PageRouter to replace currently active pages with the new route.
- Parameters
-
route The given route for the PageRouter to navigate to. A route is an array of variants or a single item. A string item will be interpreted as a page without associated data. An object item will be interpreted as follows: Navigating to a route not defined in a PageRouter's routes is undefined behavior.{"route": "/home" // The named page of the route."data": QtObject {} // The data to pass to the page.}
Definition at line 277 of file pagerouter.cpp.
◆ popRoute()
void PageRouter::popRoute | ( | ) |
Pops the last page on the router.
Calling popRoute
will result in the last page on the router getting popped. You should not call this function when there is only one page on the router.
Definition at line 367 of file pagerouter.cpp.
◆ pushRoute()
void PageRouter::pushRoute | ( | QJSValue | route | ) |
Appends a route to the currently navigated route.
Calling pushRoute
will append the given route
to the currently navigated routes. See navigateToRoute() if you want to replace the items currently on the PageRouter.
- Parameters
-
route The given route to push.
Definition at line 361 of file pagerouter.cpp.
◆ routeActive()
bool PageRouter::routeActive | ( | QJSValue | route | ) |
Check whether the current route is on the stack.
routeActive
will return true if the given route is on the stack.
- Parameters
-
route The given route to check for.
routeActive
returns true for partial routes like the following:
This only works from the root page, e.g. the following will return false:
Definition at line 342 of file pagerouter.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Jan 27 2023 07:54:59 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.