Maintain date added and date last opened.
[dorian] / model / book.h
index ded10f0..3c00e3c 100644 (file)
@@ -4,10 +4,13 @@
 #include <QString>
 #include <QStringList>
 #include <QHash>
-#include <QIcon>
+#include <QImage>
 #include <QMetaType>
 #include <QObject>
 #include <QTemporaryFile>
+#include <QDateTime>
+
+class QPixmap;
 
 /** A book. */
 class Book: public QObject
@@ -34,15 +37,15 @@ public:
         qreal pos;
         QString note;
         bool operator<(const Bookmark &other) const {
-            return (part == other.part)? (pos < other.pos): (part < other.part);
+            return (part == other.part)? (pos<other.pos): (part<other.part);
         }
     };
 
-    /** Construct a book from an EPUB file in path. */
-    Book(const QString &path, QObject *parent = 0);
+    /** Construct a book from an EPUB file. */
+    Book(const QString &fileName, QObject *parent = 0);
 
-    /** Default constructor. */
-    Book();
+    /** Destructor. */
+    ~Book();
 
     /** Load book meta-data from persistent storage. */
     void load();
@@ -101,6 +104,9 @@ public:
      */
     QString name();
 
+    /** Get cover image. */
+    QImage coverImage();
+
     /** Get short friendly name: title or file name. */
     QString shortName();
 
@@ -126,8 +132,10 @@ public:
     QString rights;                         //< Rights.
     QString tocPath;                        //< Path to toc NCX file.
     QString coverPath;                      //< Path to cover HTML file.
-    QStringList chapters;                   //< Main navigation items from EPUB.
+    QStringList chapters;                   //< Main navigation items.
     qint64 size;                            //< Size of all parts.
+    QDateTime dateAdded;                    //< Date book added to library.
+    QDateTime dateOpened;                   //< Date book was last read.
 
 signals:
     /** Emitted if @see open() succeeds. */
@@ -149,6 +157,12 @@ protected:
     /** Get location of OPS file in EPUB archive. */
     QString opsPath();
 
+    /** Make a cover image from a file. */
+    QImage makeCover(const QString &fileName);
+
+    /** Make a cover image from an pixmap. */
+    QImage makeCover(const QPixmap &pixmap);
+
     QString mPath;                          //< Path to EPUB file.
     Bookmark mLastBookmark;                 //< Last position read.
     QList<Bookmark> mBookmarks;             //< List of bookmarks.