#ifndef WORDDRILLMODEL_H #define WORDDRILLMODEL_H #include "IStudyModel.h" #include /** 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