#ifndef APPMODEL_H #define APPMODEL_H #include #include #include #include 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 > dictionaries; QString errorMessage; int curDictIndex; int curCardPackIndex; }; #endif