summaryrefslogtreecommitdiff
path: root/src/main-view/AppModel.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/main-view/AppModel.h')
-rw-r--r--src/main-view/AppModel.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/main-view/AppModel.h b/src/main-view/AppModel.h
new file mode 100644
index 0000000..bf1ddd2
--- /dev/null
+++ b/src/main-view/AppModel.h
@@ -0,0 +1,64 @@
+#ifndef APPMODEL_H
+#define APPMODEL_H
+
+#include <QList>
+#include <QPair>
+#include <QFile>
+#include <QAbstractItemModel>
+
+class Dictionary;
+class DictTableModel;
+class CardPack;
+class IStudyModel;
+
+class AppModel: public QObject
+{
+Q_OBJECT
+
+public:
+ enum StudyType
+ {
+ WordDrill,
+ SpacedRepetition,
+ StudyTypesNum
+ };
+
+public:
+ AppModel();
+ ~AppModel();
+
+ bool openDictionary( const QString& filePath );
+ void addDictionary( Dictionary* aDict );
+ Dictionary* newDictionary();
+ Dictionary* curDictionary();
+ int getCurDictIndex() const { return curDictIndex; }
+ DictTableModel* curDictModel();
+ int dictionariesNum() const { return dictionaries.size(); }
+ Dictionary* dictionary(int aIndex) const;
+ int indexOfDictionary( Dictionary* aDic ) const;
+ int indexOfDictionary( const QString& aFilePath ) const;
+ // TODO: Synchronize this with the pack tree view selection
+ int curCardPackIx() const { return curCardPackIndex; }
+ CardPack* curCardPack();
+ QString getErrorMessage() const { return errorMessage; }
+
+public slots:
+ /** @return true, if the dictionary was successfully set. false, if there are no dictionaries, or the index is out of range.
+ * If the index is out of range, the last dictionary from the list is set.
+ */
+ bool setCurDictionary(int index);
+ bool removeDictionary(int aIndex);
+ void removeDictModel(QAbstractItemModel* aDictModel);
+ IStudyModel* createStudyModel(int studyType, int cardPackIndex);
+
+private:
+ void fixupCurDictIx();
+
+private:
+ QList< QPair<Dictionary*, DictTableModel*> > dictionaries;
+ QString errorMessage;
+ int curDictIndex;
+ int curCardPackIndex;
+};
+
+#endif