Much ado about nothing.
[dorian] / library.h
index 103c3d4..a1ac176 100644 (file)
--- a/library.h
+++ b/library.h
@@ -7,6 +7,7 @@
 #include <QList>
 
 class QObject;
+class QModelIndex;
 class Book;
 
 /** Library of books. */
@@ -17,22 +18,22 @@ class Library: public QAbstractListModel
 public:
     static Library *instance();
     static void close();
-    int rowCount(const QModelIndex & parent = QModelIndex()) const;
+    int rowCount(const QModelIndex &parent = QModelIndex()) const;
     QVariant data(const QModelIndex &index, int role) const;
     void save();
-    int find(QString path) const;
-    int find(const Book *book) const;
-    Book *at(int index) const;
-    int size() const;
-    Book *current() const;
+    QModelIndex find(QString path) const;
+    QModelIndex find(const Book *book) const;
     bool add(QString path);
-    void remove(int index);
-    void setCurrent(int index);
+    void remove(const QModelIndex &index);
+    void setNowReading(const QModelIndex &index);
+    QModelIndex nowReading() const;
+    Book *book(const QModelIndex &index);
 
 signals:
-    void bookAdded();
-    void bookRemoved(int index);
-    void currentBookChanged();
+    void nowReadingChanged();
+
+public slots:
+    void onBookOpened(const QString &path);
 
 private:
     explicit Library(QObject *parent = 0);
@@ -41,7 +42,7 @@ private:
     void clear();
     static Library *mInstance;
     QList<Book *> mBooks;
-    Book *mCurrent;
+    QModelIndex mNowReading;
 };
 
 #endif // LIBRARY_H