Update from old repository.
[dorian] / dorian / library.h
1 #ifndef LIBRARY_H
2 #define LIBRARY_H
3
4 #include <QObject>
5 #include <QString>
6 #include <QList>
7
8 #include "book.h"
9
10 /** Library of books. */
11 class Library: public QObject
12 {
13     Q_OBJECT
14
15 public:
16     static Library *instance();
17     static void close();
18     void save();
19     int find(QString path) const;
20     int find(const Book *book) const;
21     Book *at(int index) const;
22     int size() const;
23     Book *current() const;
24     bool add(QString path);
25     void remove(int index);
26     void setCurrent(int index);
27
28 signals:
29     void bookAdded();
30     void bookRemoved(int index);
31     void currentBookChanged();
32
33 private:
34     Library();
35     ~Library();
36     void load();
37     void clear();
38     static Library *mInstance;
39     QList<Book *> mBooks;
40     Book *mCurrent;
41 };
42
43 #endif // LIBRARY_H