| 193 | } |
| 194 | |
| 195 | Folder DBHelper::getFolder(qulonglong libraryId, qulonglong id) |
| 196 | { |
| 197 | QString libraryPath = DBHelper::getLibraries().getPath(libraryId); |
| 198 | |
| 199 | Folder folder; |
| 200 | QString connectionName = ""; |
| 201 | |
| 202 | { |
| 203 | QSqlDatabase db = DataBaseManagement::loadDatabase(LibraryPaths::libraryDataPath(libraryPath)); |
| 204 | QSqlQuery selectQuery(db); // TODO check |
| 205 | selectQuery.prepare("SELECT * FROM folder WHERE id = :id"); |
| 206 | selectQuery.bindValue(":id", id); |
| 207 | selectQuery.exec(); |
| 208 | |
| 209 | auto record = selectQuery.record(); |
| 210 | |
| 211 | int name = record.indexOf("name"); |
| 212 | int path = record.indexOf("path"); |
| 213 | int finished = record.indexOf("finished"); |
| 214 | int completed = record.indexOf("completed"); |
| 215 | int id = record.indexOf("id"); |
| 216 | int parentId = record.indexOf("parentId"); |
| 217 | int numChildren = record.indexOf("numChildren"); |
| 218 | int firstChildHash = record.indexOf("firstChildHash"); |
| 219 | int customImage = record.indexOf("customImage"); |
| 220 | int type = record.indexOf("type"); |
| 221 | int added = record.indexOf("added"); |
| 222 | int updated = record.indexOf("updated"); |
| 223 | |
| 224 | if (selectQuery.next()) { |
| 225 | folder = Folder(selectQuery.value(id).toULongLong(), selectQuery.value(parentId).toULongLong(), selectQuery.value(name).toString(), selectQuery.value(path).toString()); |
| 226 | |
| 227 | folder.finished = selectQuery.value(finished).toBool(); |
| 228 | folder.completed = selectQuery.value(completed).toBool(); |
| 229 | if (!selectQuery.value(numChildren).isNull() && selectQuery.value(numChildren).isValid()) { |
| 230 | folder.numChildren = selectQuery.value(numChildren).toInt(); |
| 231 | } |
| 232 | folder.firstChildHash = selectQuery.value(firstChildHash).toString(); |
| 233 | folder.customImage = selectQuery.value(customImage).toString(); |
| 234 | folder.type = selectQuery.value(type).value<YACReader::FileType>(); |
| 235 | folder.added = selectQuery.value(added).toLongLong(); |
| 236 | folder.updated = selectQuery.value(updated).toLongLong(); |
| 237 | } |
| 238 | connectionName = db.connectionName(); |
| 239 | } |
| 240 | |
| 241 | QSqlDatabase::removeDatabase(connectionName); |
| 242 | return folder; |
| 243 | } |
| 244 | |
| 245 | QList<QString> DBHelper::getLibrariesNames() |
| 246 | { |
no test coverage detected