switch (role) {
case Qt::DisplayRole:
return mBooks[index.row()]->name();
+ case Qt::DecorationRole:
+ return QPixmap::fromImage(mBooks[index.row()]->cover);
default:
return QVariant();
}
QString key = "lib/book" + QString::number(i);
QString path = settings.value(key).toString();
Book *book = new Book(path);
+ connect(book, SIGNAL(opened(const QString &)),
+ this, SLOT(onBookOpened(const QString &)));
book->load();
mBooks.append(book);
}
}
return QModelIndex();
}
+
+void Library::onBookOpened(const QString &path)
+{
+ Trace t("Library::onBookOpened " + path);
+ QModelIndex index = find(path);
+ if (index.isValid()) {
+ emit dataChanged(index, index);
+ }
+}