summaryrefslogtreecommitdiff
path: root/src/mobile/keychooser/bookkeychooser.h
blob: 720e5f0277553db8e6759e59049ef14d79851502 (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
76
77
78
79
80
81
/*********
*
* In the name of the Father, and of the Son, and of the Holy Spirit.
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
**********/

#ifndef BOOK_KEY_CHOOSER_H
#define BOOK_KEY_CHOOSER_H

#include "backend/keys/cswordtreekey.h"
#include <QObject>
#include <QList>
#include <QStringList>
#include <QStandardItemModel>
#include "mobile/models/roleitemmodel.h"

class QtQuick2ApplicationViewer;
class QQmlComponent;
class QQuickItem;

namespace btm {

class BtWindowInterface;

class BookKeyChooser : public QObject {
    Q_OBJECT

    enum State {
        CLOSED,
        BOOK,
        CHAPTER,
        VERSE
    };

public:
    BookKeyChooser(QtQuick2ApplicationViewer* viewer, BtWindowInterface* windowInterface);
    void open();

signals:
    void referenceChanged();

private slots:
    void select(QString value);
    void next(QString value);
    void back();
    void stringCanceled();

private:
    void copyKey();
    void findTreeChooserObject();
    QStringList getKeyPath() const;
    void showGridChooser(const QStringList& list);
    void setProperties(const QStringList& list);
    void parseKey(QStringList * sibblings, QList<int>* hasChildrenList, CSwordTreeKey* key);
    void createModel();
    void setProperties();
    void initializeRoleNameModel();
    void populateRoleNameModel(const QStringList& sibblings, const QList<int>& sibblingChildCounts);
    void openChooser(bool open);


    QtQuick2ApplicationViewer* m_viewer;
    BtWindowInterface* m_windowInterface;
    CSwordTreeKey* m_key;
    QQuickItem* m_treeChooserObject;
    int m_state;
    QString m_backPath;
    QStringList m_sibblings;
    QStandardItemModel m_model;
    RoleItemModel m_roleItemModel;
};

} // end namespace

#endif