Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/BookListModel.cpp
Context not available. | |||||
27 | 27 | | |||
---|---|---|---|---|---|
28 | #include "AcbfAuthor.h" | 28 | #include "AcbfAuthor.h" | ||
29 | #include "AcbfSequence.h" | 29 | #include "AcbfSequence.h" | ||
30 | #include "AcbfBookinfo.h" | ||||
30 | 31 | | |||
31 | #include <kio/deletejob.h> | 32 | #include <kio/deletejob.h> | ||
33 | #include <KFileMetaData/UserMetaData> | ||||
32 | 34 | | |||
33 | #include <QCoreApplication> | 35 | #include <QCoreApplication> | ||
34 | #include <QDir> | 36 | #include <QDir> | ||
Context not available. | |||||
109 | entries.append(entry); | 111 | entries.append(entry); | ||
110 | q->append(entry); | 112 | q->append(entry); | ||
111 | titleCategoryModel->addCategoryEntry(entry->title.left(1).toUpper(), entry); | 113 | titleCategoryModel->addCategoryEntry(entry->title.left(1).toUpper(), entry); | ||
112 | authorCategoryModel->addCategoryEntry(entry->author, entry); | 114 | for (int i=0; i<entry->author.size(); i++) { | ||
113 | seriesCategoryModel->addCategoryEntry(entry->series, entry); | 115 | authorCategoryModel->addCategoryEntry(entry->author.at(i), entry); | ||
116 | } | ||||
117 | for (int i=0; i<entry->series.size(); i++) { | ||||
118 | seriesCategoryModel->addCategoryEntry(entry->series.at(i), entry); | ||||
119 | } | ||||
114 | newlyAddedCategoryModel->append(entry, CreatedRole); | 120 | newlyAddedCategoryModel->append(entry, CreatedRole); | ||
115 | QUrl url(entry->filename.left(entry->filename.lastIndexOf("/"))); | 121 | QUrl url(entry->filename.left(entry->filename.lastIndexOf("/"))); | ||
116 | folderCategoryModel->addCategoryEntry(url.path().mid(1), entry); | 122 | folderCategoryModel->addCategoryEntry(url.path().mid(1), entry); | ||
Context not available. | |||||
192 | if (!splitName.isEmpty()) | 198 | if (!splitName.isEmpty()) | ||
193 | entry->filetitle = splitName.takeLast(); | 199 | entry->filetitle = splitName.takeLast(); | ||
194 | if(!splitName.isEmpty()) | 200 | if(!splitName.isEmpty()) | ||
195 | entry->series = splitName.takeLast(); // hahahaheuristics (dumb assumptions about filesystems, go!) | 201 | entry->series = QStringList(splitName.takeLast()); // hahahaheuristics (dumb assumptions about filesystems, go!) | ||
196 | // just in case we end up without a title... using complete basename here, | 202 | // just in case we end up without a title... using complete basename here, | ||
197 | // as we would rather have "book one. part two" and the odd "book one - part two.tar" | 203 | // as we would rather have "book one. part two" and the odd "book one - part two.tar" | ||
198 | QFileInfo fileinfo(entry->filename); | 204 | QFileInfo fileinfo(entry->filename); | ||
Context not available. | |||||
210 | entry->thumbnail = QString("image://preview/").append(entry->filename); | 216 | entry->thumbnail = QString("image://preview/").append(entry->filename); | ||
211 | } | 217 | } | ||
212 | 218 | | |||
219 | KFileMetaData::UserMetaData data(entry->filename); | ||||
220 | entry->rating = data.rating(); | ||||
221 | entry->comment = data.userComment(); | ||||
222 | entry->tags = data.tags(); | ||||
223 | | ||||
213 | QVariantHash metadata = d->contentModel->data(d->contentModel->index(first, 0, index), Qt::UserRole + 2).toHash(); | 224 | QVariantHash metadata = d->contentModel->data(d->contentModel->index(first, 0, index), Qt::UserRole + 2).toHash(); | ||
214 | QVariantHash::const_iterator it = metadata.constBegin(); | 225 | QVariantHash::const_iterator it = metadata.constBegin(); | ||
215 | for (; it != metadata.constEnd(); it++) { | 226 | for (; it != metadata.constEnd(); it++) { | ||
216 | if(it.key() == QLatin1String("author")) | 227 | if(it.key() == QLatin1String("author")) | ||
217 | { entry->author = it.value().toString().trimmed(); } | 228 | { entry->author = it.value().toStringList(); } | ||
218 | else if(it.key() == QLatin1String("title")) | 229 | else if(it.key() == QLatin1String("title")) | ||
219 | { entry->title = it.value().toString().trimmed(); } | 230 | { entry->title = it.value().toString().trimmed(); } | ||
220 | else if(it.key() == QLatin1String("publisher")) | 231 | else if(it.key() == QLatin1String("publisher")) | ||
Context not available. | |||||
236 | AdvancedComicBookFormat::Document* acbfDocument = qobject_cast<AdvancedComicBookFormat::Document*>(bookModel->acbfData()); | 247 | AdvancedComicBookFormat::Document* acbfDocument = qobject_cast<AdvancedComicBookFormat::Document*>(bookModel->acbfData()); | ||
237 | if(acbfDocument) { | 248 | if(acbfDocument) { | ||
238 | for(AdvancedComicBookFormat::Sequence* sequence : acbfDocument->metaData()->bookInfo()->sequence()) { | 249 | for(AdvancedComicBookFormat::Sequence* sequence : acbfDocument->metaData()->bookInfo()->sequence()) { | ||
239 | entry->series = sequence->title(); | 250 | entry->series.append(sequence->title()); | ||
240 | break; | | |||
241 | } | 251 | } | ||
252 | for(AdvancedComicBookFormat::Author* author : acbfDocument->metaData()->bookInfo()->author()) { | ||||
253 | entry->author.append(author->displayName()); | ||||
254 | } | ||||
255 | entry->description = acbfDocument->metaData()->bookInfo()->annotation(""); | ||||
242 | } | 256 | } | ||
243 | // TODO extend the model to support multiple authors per book, ditto series/sequences | 257 | // TODO extend the model to support multiple authors per book, ditto series/sequences | ||
244 | entry->author = bookModel->author(); | 258 | if (entry->author.isEmpty()) { | ||
259 | entry->author.append(bookModel->author()); | ||||
260 | } | ||||
245 | entry->title = bookModel->title(); | 261 | entry->title = bookModel->title(); | ||
246 | entry->publisher = bookModel->publisher(); | 262 | entry->publisher = bookModel->publisher(); | ||
247 | entry->totalPages = bookModel->pageCount(); | 263 | entry->totalPages = bookModel->pageCount(); | ||
Context not available. | |||||
312 | { | 328 | { | ||
313 | entry->currentPage = value.toInt(); | 329 | entry->currentPage = value.toInt(); | ||
314 | } | 330 | } | ||
331 | else if(property == "rating") | ||||
332 | { | ||||
333 | entry->rating = value.toInt(); | ||||
334 | } | ||||
335 | else if(property == "tags") | ||||
336 | { | ||||
337 | entry->tags = value.split(","); | ||||
338 | } | ||||
339 | else if(property == "comment") { | ||||
340 | entry->comment = value; | ||||
341 | } | ||||
315 | emit entryDataUpdated(entry); | 342 | emit entryDataUpdated(entry); | ||
316 | break; | 343 | break; | ||
317 | } | 344 | } | ||
Context not available. |