summaryrefslogtreecommitdiff
path: root/src/frontend/keychooser/bthistory.h
blob: a92a25e2aea82933e4aaa53bdb01c4832223b021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#ifndef BTHISTORY_H
#define BTHISTORY_H

#include <QObject>

#include <QList>


class CSwordKey;
class QAction;
class QWidget;

class BTHistory: public QObject {
        Q_OBJECT
    public:
        BTHistory(QWidget* parent);

        /**
        * Return a list of Actions behind the current point, the first of the history list will be the
        * last in the returned list and vice versa.
        */
        QList<QAction*> getBackList();
        /**
        * Return a list of Actions after the current point.
        */
        QList<QAction*> getFwList();

    public slots:
        /**
        * Add a new key to the history.
        */
        void add(CSwordKey* newKey);
        /**
        * Move the current point in history list.
        */
        void move(QAction*);
        /**
        * Go back one step in history.
        */
        void back();
        /**
        * Go forward one step in history.
        */
        void fw();

    signals:
        /**
        * Signal will be sent when the history has been changed (added, moved)
        */
        void historyChanged(bool backEnabled, bool fwEnabled);
        /**
        * Signal will be sent when the current point in history has moved
        */
        void historyMoved(QString& newKey);

    private:

        void sendChangedSignal();
        bool class_invariant();

        QList<QAction*> m_historyList;
        int m_index; //pointer to the current item; -1==empty, 0==first etc.
        bool m_inHistoryFunction; //to prevent recursive behaviour
};

#endif