void GameUI::StartGameImageSet(MythGenericTree *node, QStringList coverart, QStringList fanart, QStringList screenshot) { if (!node) return; RomInfo *metadata = qVariantValue<RomInfo *>(node->GetData()); if (!metadata) return; ArtworkMap map; QString inetref = metadata->Inetref(); QString system = metadata->System(); QString title = metadata->Gamename(); if (metadata->Boxart().isEmpty() && coverart.size()) { ArtworkInfo info; info.url = coverart.takeAt(0).trimmed(); map.insert(kArtworkCoverart, info); } if (metadata->Fanart().isEmpty() && fanart.size()) { ArtworkInfo info; info.url = fanart.takeAt(0).trimmed(); map.insert(kArtworkFanart, info); } if (metadata->Screenshot().isEmpty() && screenshot.size()) { ArtworkInfo info; info.url = screenshot.takeAt(0).trimmed(); map.insert(kArtworkScreenshot, info); } MetadataLookup *lookup = new MetadataLookup(); lookup->SetTitle(metadata->Gamename()); lookup->SetSystem(metadata->System()); lookup->SetInetref(metadata->Inetref()); lookup->SetType(kMetadataGame); lookup->SetDownloads(map); lookup->SetData(qVariantFromValue(node)); m_imageDownload->addDownloads(lookup); }
void GameUI::gameSearch(MythGenericTree *node, bool automode) { if (!node) node = m_gameUITree->GetCurrentNode(); if (!node) return; RomInfo *metadata = qVariantValue<RomInfo *>(node->GetData()); if (!metadata) return; MetadataLookup *lookup = new MetadataLookup(); lookup->SetStep(kLookupSearch); lookup->SetType(kMetadataGame); lookup->SetData(qVariantFromValue(node)); if (automode) { lookup->SetAutomatic(true); } lookup->SetTitle(metadata->Gamename()); lookup->SetInetref(metadata->Inetref()); if (m_query->isRunning()) m_query->prependLookup(lookup); else m_query->addLookup(lookup); if (!automode) { //: %1 is the game name QString msg = tr("Fetching details for %1") .arg(metadata->Gamename()); createBusyDialog(msg); } }
void GameUI::fillNode(MythGenericTree *node) { QString layername = node->GetText(); RomInfo *romInfo = qVariantValue<RomInfo *>(node->GetData()); MSqlQuery query(MSqlQuery::InitCon()); query.prepare(getFillSql(node)); if (romInfo) { if (!romInfo->System().isEmpty()) query.bindValue(":SYSTEM", romInfo->System()); if (!romInfo->Year().isEmpty()) query.bindValue(":YEAR", romInfo->Year()); if (!romInfo->Genre().isEmpty()) query.bindValue(":GENRE", romInfo->Genre()); if (!romInfo->Plot().isEmpty()) query.bindValue(":PLOT", romInfo->Plot()); if (!romInfo->Publisher().isEmpty()) query.bindValue(":PUBLISHER", romInfo->Publisher()); if (!romInfo->Gamename().isEmpty()) query.bindValue(":GAMENAME", romInfo->Gamename()); } bool IsLeaf = node->getInt() == getLevelsOnThisBranch(node); if (query.exec() && query.size() > 0) { while (query.next()) { QString current = query.value(0).toString().trimmed(); MythGenericTree *new_node = new MythGenericTree(current, node->getInt() + 1, false); if (IsLeaf) { RomInfo *temp = new RomInfo(); temp->setSystem(query.value(1).toString().trimmed()); temp->setYear(query.value(2).toString()); temp->setGenre(query.value(3).toString().trimmed()); temp->setGamename(query.value(4).toString().trimmed()); new_node->SetData(qVariantFromValue(temp)); node->addNode(new_node); } else { RomInfo *newRomInfo; if (node->getInt() > 1) { RomInfo *currentRomInfo; currentRomInfo = qVariantValue<RomInfo *>(node->GetData()); newRomInfo = new RomInfo(*currentRomInfo); } else { newRomInfo = new RomInfo(); } new_node->SetData(qVariantFromValue(newRomInfo)); node->addNode(new_node); if (getChildLevelString(node) != "hash") newRomInfo->setField(getChildLevelString(node), current); } } } }
QString GameUI::getFillSql(MythGenericTree *node) const { QString layer = node->GetText(); int childDepth = node->getInt() + 1; QString childLevel = getChildLevelString(node); QString filter = getFilter(node); bool childIsLeaf = childDepth == getLevelsOnThisBranch(node) + 1; RomInfo *romInfo = qVariantValue<RomInfo *>(node->GetData()); QString columns; QString conj = "where "; if (!filter.isEmpty()) { filter = conj + filter; conj = " and "; } if ((childLevel == "gamename") && (m_gameShowFileName)) { columns = childIsLeaf ? "romname,system,year,genre,gamename" : "romname"; if (m_showHashed) filter += " and romname like '" + layer + "%'"; } else if ((childLevel == "gamename") && (layer.length() == 1)) { columns = childIsLeaf ? childLevel + ",system,year,genre,gamename" : childLevel; if (m_showHashed) filter += " and gamename like '" + layer + "%'"; } else if (childLevel == "hash") { columns = "left(gamename,1)"; } else { columns = childIsLeaf ? childLevel + ",system,year,genre,gamename" : childLevel; } // this whole section ought to be in rominfo.cpp really, but I've put it // in here for now to minimise the number of files changed by this mod if (romInfo) { if (!romInfo->System().isEmpty()) { filter += conj + "trim(system)=:SYSTEM"; conj = " and "; } if (!romInfo->Year().isEmpty()) { filter += conj + "year=:YEAR"; conj = " and "; } if (!romInfo->Genre().isEmpty()) { filter += conj + "trim(genre)=:GENRE"; conj = " and "; } if (!romInfo->Plot().isEmpty()) { filter += conj + "plot=:PLOT"; conj = " and "; } if (!romInfo->Publisher().isEmpty()) { filter += conj + "publisher=:PUBLISHER"; conj = " and "; } if (!romInfo->Gamename().isEmpty()) { filter += conj + "trim(gamename)=:GAMENAME"; } } filter += conj + " display = 1 "; QString sql; if ((childLevel == "gamename") && (m_gameShowFileName)) { sql = "select distinct " + columns + " from gamemetadata " + filter + " order by romname" + ";"; } else if (childLevel == "hash") { sql = "select distinct " + columns + " from gamemetadata " + filter + " order by gamename,romname" + ";"; } else { sql = "select distinct " + columns + " from gamemetadata " + filter + " order by " + childLevel + ";"; } return sql; }
void GameUI::customEvent(QEvent *event) { if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = (DialogCompletionEvent*)(event); QString resultid = dce->GetId(); QString resulttext = dce->GetResultText(); if (resultid == "showMenuPopup") { if (resulttext == tr("Edit Details")) { edit(); } if (resulttext == tr("Scan For Changes")) { doScan(); } else if (resulttext == tr("Show Information")) { showInfo(); } else if (resulttext == tr("Make Favorite") || resulttext == tr("Remove Favorite")) { toggleFavorite(); } else if (resulttext == tr("Retrieve Details")) { gameSearch(); } } else if (resultid == "chooseSystemPopup") { if (!resulttext.isEmpty() && resulttext != tr("Cancel")) { MythGenericTree *node = m_gameUITree->GetCurrentNode(); RomInfo *romInfo = qVariantValue<RomInfo *>(node->GetData()); GameHandler::Launchgame(romInfo, resulttext); } } else if (resultid == "editMetadata") { MythGenericTree *node = m_gameUITree->GetCurrentNode(); RomInfo *oldRomInfo = qVariantValue<RomInfo *>(node->GetData()); delete oldRomInfo; RomInfo *romInfo = qVariantValue<RomInfo *>(dce->GetData()); node->SetData(qVariantFromValue(romInfo)); node->SetText(romInfo->Gamename()); romInfo->SaveToDatabase(); updateChangedNode(node, romInfo); } else if (resultid == "detailsPopup") { // Play button pushed itemClicked(0); } } if (event->type() == MetadataLookupEvent::kEventType) { MetadataLookupEvent *lue = (MetadataLookupEvent *)event; MetadataLookupList lul = lue->lookupList; if (m_busyPopup) { m_busyPopup->Close(); m_busyPopup = NULL; } if (lul.isEmpty()) return; if (lul.count() == 1) { OnGameSearchDone(lul.takeFirst()); } else { MetadataResultsDialog *resultsdialog = new MetadataResultsDialog(m_popupStack, lul); connect(resultsdialog, SIGNAL(haveResult(MetadataLookup*)), SLOT(OnGameSearchListSelection(MetadataLookup*)), Qt::QueuedConnection); if (resultsdialog->Create()) m_popupStack->AddScreen(resultsdialog); } } else if (event->type() == MetadataLookupFailure::kEventType) { MetadataLookupFailure *luf = (MetadataLookupFailure *)event; MetadataLookupList lul = luf->lookupList; if (m_busyPopup) { m_busyPopup->Close(); m_busyPopup = NULL; } if (lul.size()) { MetadataLookup *lookup = lul.takeFirst(); MythGenericTree *node = qVariantValue<MythGenericTree *>(lookup->GetData()); if (node) { RomInfo *metadata = qVariantValue<RomInfo *>(node->GetData()); if (metadata) { } } LOG(VB_GENERAL, LOG_ERR, QString("No results found for %1").arg(lookup->GetTitle())); } } else if (event->type() == ImageDLEvent::kEventType) { ImageDLEvent *ide = (ImageDLEvent *)event; MetadataLookup *lookup = ide->item; if (!lookup) return; handleDownloadedImages(lookup); } }