summaryrefslogtreecommitdiff
path: root/src/study/WordDrillModel.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/study/WordDrillModel.h')
-rw-r--r--src/study/WordDrillModel.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/study/WordDrillModel.h b/src/study/WordDrillModel.h
new file mode 100644
index 0000000..7db780a
--- /dev/null
+++ b/src/study/WordDrillModel.h
@@ -0,0 +1,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