Make progress indicator more subtle.
[dorian] / model / library.h
1 #ifndef LIBRARY_H
2 #define LIBRARY_H
3
4 #include <QAbstractListModel>
5 #include <QVariant>
6 #include <QString>
7 #include <QList>
8 #include <QStringList>
9
10 class QObject;
11 class Book;
12
13 /** Library of books. */
14 class Library: public QAbstractListModel
15 {
16     Q_OBJECT
17
18 public:
19     static Library *instance();
20     static void close();
21     int rowCount(const QModelIndex &parent = QModelIndex()) const;
22     QVariant data(const QModelIndex &index, int role) const;
23     void load();
24     void save();
25     QModelIndex find(QString path) const;
26     QModelIndex find(const Book *book) const;
27     void setNowReading(const QModelIndex &index);
28     QModelIndex nowReading() const;
29     Book *book(const QModelIndex &index);
30     QStringList bookPaths();
31     void upgrade();
32
33 signals:
34     void nowReadingChanged();
35     void beginUpgrade(int total);
36     void upgrading(const QString &book);
37     void endUpgrade();
38     void beginLoad(int total);
39     void loading(const QString &book);
40     void endLoad();
41
42 public slots:
43     bool add(const QString &path);
44     void remove(const QString &path);
45     void remove(const QModelIndex &index);
46     void onBookOpened(const QString &path);
47
48 private:
49     explicit Library(QObject *parent = 0);
50     ~Library();
51     void clear();
52     QList<Book *> mBooks;
53     QModelIndex mNowReading;
54 };
55
56 #endif // LIBRARY_H