| 206 | } |
| 207 | |
| 208 | void ViewStateHandler::loadPlaylist(const QDomElement &viewStateNode) |
| 209 | { |
| 210 | // In order to get the pointers to the right playlist items, we need a list of all playlist items |
| 211 | QList<playlistItem *> allPlaylistItems = playlist->getAllPlaylistItems(); |
| 212 | |
| 213 | auto n = viewStateNode.firstChild(); |
| 214 | while (!n.isNull()) |
| 215 | { |
| 216 | auto elem = YUViewDomElement(n.toElement()); |
| 217 | if (!n.isElement()) |
| 218 | { |
| 219 | n = n.nextSibling(); |
| 220 | continue; |
| 221 | } |
| 222 | n = n.nextSibling(); |
| 223 | |
| 224 | auto name = elem.tagName(); |
| 225 | if (!name.startsWith("slot") && name != "current") |
| 226 | continue; |
| 227 | |
| 228 | auto id = name.right(1).toInt(); |
| 229 | if (name != "current" && (id < 0 || id >= 8)) |
| 230 | continue; |
| 231 | |
| 232 | // Get all the values from the entry |
| 233 | auto frameIdx = elem.findChildValue("frameIdx").toInt(); |
| 234 | |
| 235 | // Get the selection item ID's (set to -1 if not found) |
| 236 | bool ok; |
| 237 | int itemId1 = elem.findChildValue("itemID1").toInt(&ok); |
| 238 | if (!ok) |
| 239 | itemId1 = -1; |
| 240 | int itemId2 = elem.findChildValue("itemID2").toInt(&ok); |
| 241 | if (!ok) |
| 242 | itemId2 = -1; |
| 243 | |
| 244 | int centerOffsetX = elem.findChildValue("centerOffsetX").toInt(); |
| 245 | int centerOffsetY = elem.findChildValue("centerOffsetY").toInt(); |
| 246 | int viewMode = elem.findChildValue("viewMode").toInt(); |
| 247 | double splittingPoint = 0.5; |
| 248 | if (viewMode != 0) |
| 249 | splittingPoint = elem.findChildValue("splittingPoint").toDouble(); |
| 250 | double zoomFactor = elem.findChildValue("zoomFactor").toDouble(); |
| 251 | |
| 252 | // Perform a quick check if the values seem correct |
| 253 | if (frameIdx < 0 || itemId1 < -1 || itemId2 < -1) |
| 254 | continue; |
| 255 | if (viewMode != 0 && (splittingPoint < 0 || splittingPoint > 1)) |
| 256 | continue; |
| 257 | if (viewMode < 0 || viewMode > 2 || zoomFactor < 0) |
| 258 | continue; |
| 259 | |
| 260 | // Everything seems to be OK |
| 261 | // Search through the allPlaylistItems list and get the pointer to the item with the given |
| 262 | // playlist id |
| 263 | playlistItem *item1 = nullptr; |
| 264 | playlistItem *item2 = nullptr; |
| 265 | for (int i = 0; i < allPlaylistItems.count(); i++) |
no test coverage detected