| 164 | } |
| 165 | |
| 166 | void YACReaderLibraries::load() |
| 167 | { |
| 168 | QSettings settings(YACReader::getSettingsPath() + "/" + QCoreApplication::applicationName() + ".ini", QSettings::IniFormat); |
| 169 | |
| 170 | if (settings.value(LIBRARIES).isValid()) { |
| 171 | QByteArray data = settings.value(LIBRARIES).toByteArray(); |
| 172 | |
| 173 | // in 9.14 the format of libraries has changed, so we need to check if we can do a migration |
| 174 | QDataStream legacyIn(&data, QIODevice::ReadOnly); |
| 175 | QMap<QString, QPair<int, QString>> legacyLibraries; |
| 176 | legacyIn >> legacyLibraries; |
| 177 | |
| 178 | auto needsMigration = !legacyLibraries.isEmpty(); |
| 179 | if (needsMigration) { |
| 180 | QList<YACReaderLibrary> migratedLibraries; |
| 181 | |
| 182 | for (auto i = legacyLibraries.cbegin(), end = legacyLibraries.cend(); i != end; ++i) { |
| 183 | auto name = i.key(); |
| 184 | auto value = i.value(); |
| 185 | auto newId = QUuid::createUuid(); |
| 186 | |
| 187 | writeIdToLibraryFolder(value.second, newId); |
| 188 | |
| 189 | auto library = YACReaderLibrary(name, value.second, value.first, newId); |
| 190 | migratedLibraries.append(library); |
| 191 | } |
| 192 | |
| 193 | libraries = migratedLibraries; |
| 194 | save(); |
| 195 | } else { |
| 196 | QDataStream in(&data, QIODevice::ReadOnly); |
| 197 | in >> libraries; |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | bool YACReaderLibraries::save() |
| 203 | { |
no test coverage detected