QVariant Library::data(const QModelIndex &index, int role) const
{
- TRACE;
-
QVariant ret;
if (!index.isValid()) {
return ret;
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:
;
beginInsertRows(QModelIndex(), size, size);
Book *book = new Book(path);
book->peek();
+ book->dateAdded = QDateTime::currentDateTime().toUTC();
mBooks.append(book);
save();
endInsertRows();
void Library::remove(const QString &path)
{
+ TRACE;
remove(find(path));
}
void Library::clear()
{
+ TRACE;
for (int i = 0; i < mBooks.size(); i++) {
delete mBooks[i];
}
QModelIndex Library::find(QString path) const
{
+ TRACE;
if (path != "") {
QString absolutePath = QFileInfo(path).absoluteFilePath();
for (int i = 0; i < mBooks.size(); i++) {
QModelIndex Library::find(const Book *book) const
{
+ TRACE;
if (book) {
for (int i = 0; i < mBooks.size(); i++) {
if (book == mBooks[i]) {