MCPcopy Create free account
hub / github.com/IENT/YUView / loadPlaylist

Method loadPlaylist

YUViewLib/src/ui/ViewStateHandler.cpp:208–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void 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++)

Callers 1

Calls 8

YUViewDomElementClass · 0.85
getAllPlaylistItemsMethod · 0.80
findChildValueMethod · 0.80
propertiesMethod · 0.80
setSelectedItemsMethod · 0.80
setViewStateMethod · 0.80
resetPlaylistIDMethod · 0.80

Tested by

no test coverage detected