72
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CNTVIEWNAVIGATOR_H_
|
|
19 |
#define CNTVIEWNAVIGATOR_H_
|
|
20 |
#include <QObject>
|
|
21 |
#include <QStack>
|
|
22 |
#include <hbnamespace.h>
|
|
23 |
#include "cntglobal.h"
|
|
24 |
/*!
|
|
25 |
* Navigator keeps track on view history, the path that user has
|
|
26 |
* gone throug. If back() is called, one step back view id
|
|
27 |
* given, unless exception is set to current view id. In case of
|
|
28 |
* exception, navigator goes back in history until the exception
|
|
29 |
* value is found. Note the difference between "back with exeception" vs.
|
|
30 |
* "launching given view id" (next()).
|
|
31 |
*
|
|
32 |
* Next goes one step forward and stores history.
|
|
33 |
* Navigator is implemented as stack of view ids.
|
|
34 |
*
|
|
35 |
*/
|
|
36 |
class QTPBK_EXPORT CntViewNavigator : public QObject
|
|
37 |
{
|
|
38 |
Q_OBJECT
|
|
39 |
friend class T_NavigatorTest;
|
|
40 |
|
|
41 |
public:
|
|
42 |
CntViewNavigator( QObject* aParent );
|
|
43 |
~CntViewNavigator();
|
|
44 |
|
|
45 |
public:
|
|
46 |
/*!
|
|
47 |
* Next view puts the given id as current view
|
|
48 |
*/
|
|
49 |
void next( const int& aId, QFlags<Hb::ViewSwitchFlag> &flags );
|
|
50 |
|
|
51 |
/*!
|
|
52 |
* Back view returns the previous view
|
|
53 |
*/
|
|
54 |
const int& back( QFlags<Hb::ViewSwitchFlag> &flags, bool toRoot );
|
|
55 |
|
|
56 |
/*!
|
|
57 |
* Add exceptions to next/back mechanism. Function will use the aBack argument
|
|
58 |
* for previous view when aCurrent is the active view.
|
|
59 |
*/
|
|
60 |
void addException( const int& aCurrent, const int& aBack );
|
|
61 |
void removeException( const int& aCurrent );
|
|
62 |
|
|
63 |
/*!
|
|
64 |
* Add special view switching effects for some of the views.
|
|
65 |
*/
|
|
66 |
void addEffect( const int& aCurrent, const int& aBack );
|
|
67 |
void removeEffect( const int& aCurrent );
|
|
68 |
|
|
69 |
/*!
|
|
70 |
* Set a view as a root view.
|
|
71 |
*/
|
|
72 |
void addRoot( const int& aCurrent );
|
81
|
73 |
|
|
74 |
/*!
|
|
75 |
* Internalize view data. Returns the previous view id.
|
|
76 |
*/
|
|
77 |
int internalize(QDataStream &stream);
|
|
78 |
|
|
79 |
/*!
|
|
80 |
* Externalize view data.
|
|
81 |
*/
|
|
82 |
void externalize(QDataStream &stream);
|
|
83 |
|
|
84 |
/*!
|
|
85 |
* Clear view stack.
|
|
86 |
*/
|
|
87 |
void clearViewStack();
|
72
|
88 |
|
|
89 |
private:
|
81
|
90 |
QStack<int> mViewStack;
|
|
91 |
QMap< int, int > mExceptions;
|
|
92 |
QMap< int, int > mEffects;
|
|
93 |
QList<int> mRoots;
|
|
94 |
int mTop;
|
|
95 |
int mPreviousViewId;
|
72
|
96 |
};
|
|
97 |
#endif /* CNTVIEWNAVIGATOR_H_ */
|