summaryrefslogtreecommitdiff
path: root/src/dictionary/IDictionary.h
blob: bfc82bc424f7afd9ea1a2fc3c5a48b5e7dd75309 (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
#ifndef IDICTIONARY_H
#define IDICTIONARY_H

#include <QtCore>

class DicRecord;
class Field;
class CardPack;

class IDictionary
{
public:
    static const int AllFields = -1;

public:
    IDictionary(const QString& filePath = ""):
        filePath(filePath) {}
    virtual ~IDictionary();

    void addRecord(DicRecord* record);
    void addRecords(const QList<DicRecord*>& records);
    QList<DicRecord*> getRecords() const { return records; }

    virtual const Field* field( int aIx ) const = 0;
    virtual const Field* field( const QString aFieldName ) const = 0;
    virtual int indexOfCardPack( CardPack* aPack ) const = 0;

    virtual void addCardPack(CardPack* aCardPack) = 0;

    virtual QFile::FileError saveStudy() { return QFile::NoError; }

    // Stats
    int countTodaysAllCards() const;
    int countTodaysNewCards() const;

    QString extendImagePaths(QString text) const;
    QString getImagesPath() const;

protected:
    virtual void notifyRecordsInserted(int /*index*/, int /*num*/) {}

private:
    static QString replaceImagePaths(QString text, const QString& shortDir,
        const QString& replacingPath);

protected:
    QString filePath;
    QList<DicRecord*> records;
    QList<CardPack*> m_cardPacks;
};
#endif