blob: 7db780a576f09b53f3405348ec8da9249c43d40e (
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
|
#ifndef WORDDRILLMODEL_H
#define WORDDRILLMODEL_H
#include "IStudyModel.h"
#include <QStringList>
/** Model of Word Drill study tool.
*
* At the beginning of a test, the model generates a fresh pack of valid cards: #m_freshPack. In course of the test,
* cards one-by-one are randomly taken from the fresh pack and moved to the history pack #m_cardHistory.
* The part of history, which belongs to the current pack (recently generated new pack), is separated from older
* cards with property #m_historyCurPackStart.
* The current card can be obtained with #curCard(), it is taken from the history. When the fresh pack is finished
* and the next card required, new fresh pack is generated.
*
* All used cards over all pack iterations are saved to the history.
* The user can travel back and forth along the history with goBack() and goForward(). In this case #m_curCardNum
* increases or decreases.
*/
class WordDrillModel: public IStudyModel
{
Q_OBJECT
public:
WordDrillModel( CardPack* aCardPack );
Card* getCurCard() const;
bool canGoBack();
bool canGoForward();
int getCurCardNum() const { return curCardNum; }
int historySize() const {return m_cardHistory.size(); }
private:
void generateFreshPack();
void cleanHistoryFromRemovedCards();
public slots:
void pickNextCard();
bool goBack();
bool goForward();
private slots:
void updateStudyState();
private:
static const int NoCardIndex = -1;
private:
/** Fresh cards. The cards that were not shown yet (in the current iteration). Not own.*/
QStringList m_freshPack;
/// List of all shown cards. Not own.
QStringList m_cardHistory;
/// The start index of the current pack in the history
int m_historyCurPackStart;
};
#endif
|