New version 0.4.6.
[dorian] / model / library.cpp
index 144d9e5..14082e5 100644 (file)
@@ -37,8 +37,6 @@ int Library::rowCount(const QModelIndex &parent) const
 
 QVariant Library::data(const QModelIndex &index, int role) const
 {
-    TRACE;
-
     QVariant ret;
     if (!index.isValid()) {
         return ret;
@@ -46,12 +44,10 @@ QVariant Library::data(const QModelIndex &index, int role) const
 
     switch (role) {
     case Qt::DisplayRole:
-        qDebug() << mBooks[index.row()]->name();
         ret = mBooks[index.row()]->name();
         break;
     case Qt::DecorationRole:
-        qDebug() << "(cover)";
-        ret.setValue(mBooks[index.row()]->cover);
+        ret.setValue(mBooks[index.row()]->coverImage());
         break;
     default:
         ;
@@ -125,6 +121,7 @@ bool Library::add(const QString &path)
     beginInsertRows(QModelIndex(), size, size);
     Book *book = new Book(path);
     book->peek();
+    book->dateAdded = QDateTime::currentDateTime().toUTC();
     mBooks.append(book);
     save();
     endInsertRows();
@@ -153,6 +150,7 @@ void Library::remove(const QModelIndex &index)
 
 void Library::remove(const QString &path)
 {
+    TRACE;
     remove(find(path));
 }
 
@@ -170,6 +168,7 @@ void Library::setNowReading(const QModelIndex &index)
 
 void Library::clear()
 {
+    TRACE;
     for (int i = 0; i < mBooks.size(); i++) {
         delete mBooks[i];
     }
@@ -179,6 +178,7 @@ void Library::clear()
 
 QModelIndex Library::find(QString path) const
 {
+    TRACE;
     if (path != "") {
         QString absolutePath = QFileInfo(path).absoluteFilePath();
         for (int i = 0; i < mBooks.size(); i++) {
@@ -192,6 +192,7 @@ QModelIndex Library::find(QString path) const
 
 QModelIndex Library::find(const Book *book) const
 {
+    TRACE;
     if (book) {
         for (int i = 0; i < mBooks.size(); i++) {
             if (book == mBooks[i]) {