Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/BookListModel.cpp
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 140 | void loadCache(BookListModel* q) { | |||
---|---|---|---|---|---|
141 | QList<BookEntry*> entries = db->loadEntries(); | 141 | QList<BookEntry*> entries = db->loadEntries(); | ||
142 | if(entries.count() > 0) | 142 | if(entries.count() > 0) | ||
143 | { | 143 | { | ||
144 | initializeSubModels(q); | 144 | initializeSubModels(q); | ||
145 | } | 145 | } | ||
146 | int i = 0; | 146 | int i = 0; | ||
147 | foreach(BookEntry* entry, entries) | 147 | foreach(BookEntry* entry, entries) | ||
148 | { | 148 | { | ||
149 | /* | ||||
150 | * This might turn out a little slow, but we should avoid having entries | ||||
151 | * that do not exist. If we end up with slowdown issues when loading the | ||||
152 | * cache this would be a good place to start investigating. | ||||
153 | */ | ||||
154 | if (QFileInfo::exists(entry->filename)) { | ||||
149 | addEntry(q, entry); | 155 | addEntry(q, entry); | ||
150 | if(++i % 100 == 0) { | 156 | if(++i % 100 == 0) { | ||
151 | emit q->countChanged(); | 157 | emit q->countChanged(); | ||
152 | qApp->processEvents(); | 158 | qApp->processEvents(); | ||
153 | } | 159 | } | ||
160 | } else { | ||||
161 | db->removeEntry(entry); | ||||
162 | } | ||||
154 | } | 163 | } | ||
155 | cacheLoaded = true; | 164 | cacheLoaded = true; | ||
156 | emit q->cacheLoadedChanged(); | 165 | emit q->cacheLoadedChanged(); | ||
157 | } | 166 | } | ||
158 | }; | 167 | }; | ||
159 | 168 | | |||
160 | BookListModel::BookListModel(QObject* parent) | 169 | BookListModel::BookListModel(QObject* parent) | ||
161 | : CategoryEntriesModel(parent) | 170 | : CategoryEntriesModel(parent) | ||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Line(s) | 396 | if(deleteFile) { | |||
389 | job->start(); | 398 | job->start(); | ||
390 | } | 399 | } | ||
391 | 400 | | |||
392 | Q_FOREACH(BookEntry* entry, d->entries) | 401 | Q_FOREACH(BookEntry* entry, d->entries) | ||
393 | { | 402 | { | ||
394 | if(entry->filename == fileName) | 403 | if(entry->filename == fileName) | ||
395 | { | 404 | { | ||
396 | emit entryRemoved(entry); | 405 | emit entryRemoved(entry); | ||
406 | d->db->removeEntry(entry); | ||||
397 | delete entry; | 407 | delete entry; | ||
398 | break; | 408 | break; | ||
399 | } | 409 | } | ||
400 | } | 410 | } | ||
401 | } | 411 | } | ||
402 | 412 | | |||
403 | QStringList BookListModel::knownBookFiles() const | 413 | QStringList BookListModel::knownBookFiles() const | ||
404 | { | 414 | { | ||
405 | QStringList files; | 415 | QStringList files; | ||
406 | foreach(BookEntry* entry, d->entries) { | 416 | foreach(BookEntry* entry, d->entries) { | ||
407 | files.append(entry->filename); | 417 | files.append(entry->filename); | ||
408 | } | 418 | } | ||
409 | return files; | 419 | return files; | ||
410 | } | 420 | } |