Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/BookListModel.cpp
Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Line(s) | 176 | { | |||
---|---|---|---|---|---|
177 | return d->contentModel; | 177 | return d->contentModel; | ||
178 | } | 178 | } | ||
179 | 179 | | |||
180 | void BookListModel::contentModelItemsInserted(QModelIndex index, int first, int last) | 180 | void BookListModel::contentModelItemsInserted(QModelIndex index, int first, int last) | ||
181 | { | 181 | { | ||
182 | d->initializeSubModels(this); | 182 | d->initializeSubModels(this); | ||
183 | int newRow = d->entries.count(); | 183 | int newRow = d->entries.count(); | ||
184 | beginInsertRows(QModelIndex(), newRow, newRow + (last - first)); | 184 | beginInsertRows(QModelIndex(), newRow, newRow + (last - first)); | ||
185 | int role = d->contentModel->roleNames().key("filePath"); | ||||
185 | for(int i = first; i < last + 1; ++i) | 186 | for(int i = first; i < last + 1; ++i) | ||
186 | { | 187 | { | ||
187 | QVariant filename = d->contentModel->data(d->contentModel->index(first, 0, index), Qt::UserRole + 1); | 188 | QVariant filePath = d->contentModel->data(d->contentModel->index(first, 0, index), role); | ||
188 | BookEntry* entry = new BookEntry(); | 189 | BookEntry* entry = new BookEntry(); | ||
189 | entry->filename = filename.toString(); | 190 | entry->filename = filePath.toUrl().toLocalFile(); | ||
190 | QStringList splitName = entry->filename.split("/"); | 191 | QStringList splitName = entry->filename.split("/"); | ||
191 | if (!splitName.isEmpty()) | 192 | if (!splitName.isEmpty()) | ||
192 | entry->filetitle = splitName.takeLast(); | 193 | entry->filetitle = splitName.takeLast(); | ||
193 | if(!splitName.isEmpty()) | 194 | if(!splitName.isEmpty()) | ||
194 | entry->series = splitName.takeLast(); // hahahaheuristics (dumb assumptions about filesystems, go!) | 195 | entry->series = splitName.takeLast(); // hahahaheuristics (dumb assumptions about filesystems, go!) | ||
195 | // just in case we end up without a title... using complete basename here, | 196 | // just in case we end up without a title... using complete basename here, | ||
196 | // as we would rather have "book one. part two" and the odd "book one - part two.tar" | 197 | // as we would rather have "book one. part two" and the odd "book one - part two.tar" | ||
197 | QFileInfo fileinfo(entry->filename); | 198 | QFileInfo fileinfo(entry->filename); | ||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |