Go to the documentation of this file.
74 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'gameui'");
105 QString systemFilter;
111 for (
unsigned i = 0; i < handlercount; ++i)
115 systemFilter =
"`system` in ('" + system +
"'";
117 systemFilter +=
",'" + system +
"'";
119 if (systemFilter.isEmpty())
121 systemFilter =
"1=0";
122 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find any game handlers!"));
136 new_node->SetData(QVariant::fromValue(
137 new GameTreeInfo(levels, systemFilter +
" and favorite=1")));
144 int pos = levels.indexOf(
"gamename");
146 levels.insert(pos,
" hash ");
150 new_node->SetData(QVariant::fromValue(
155 new_node->SetData(QVariant::fromValue(
160 new_node->SetData(QVariant::fromValue(
165 new_node->SetData(QVariant::fromValue(
170 new_node->SetData(QVariant::fromValue(
186 for (
int i = 0; i < actions.size() && !handled; i++)
188 QString
action = actions[i];
193 else if (
action ==
"EDIT")
195 else if (
action ==
"INFO")
197 else if (
action ==
"TOGGLEFAV")
199 else if ((
action ==
"INCSEARCH") || (
action ==
"INCSEARCHNEXT"))
201 else if (
action ==
"DOWNLOADDATA")
232 if (romInfo->Romname().isEmpty())
235 if (!romInfo->Screenshot().isEmpty() || !romInfo->Fanart().isEmpty() ||
236 !romInfo->Boxart().isEmpty())
258 if (romInfo->RomCount() == 1)
265 QString msg = tr(
"Choose System for:\n%1").arg(node->
GetText());
267 GetStack(
"popup stack");
269 msg, popupStack,
"chooseSystemPopup");
271 if (chooseSystemPopup->Create())
273 chooseSystemPopup->SetReturnEvent(
this,
"chooseSystemPopup");
274 QString all_systems = romInfo->AllSystems();
275 QStringList players = all_systems.split(
',');
276 for (
const auto & player : qAsConst(players))
277 chooseSystemPopup->AddButton(player);
278 popupStack->
AddScreen(chooseSystemPopup);
281 delete chooseSystemPopup;
383 "mythgameeditmetadata", romInfo);
385 if (md_editor->Create())
387 screenStack->AddScreen(md_editor);
388 md_editor->SetReturnEvent(
this,
"editMetadata");
406 if (details_dialog->Create())
409 details_dialog->SetReturnEvent(
this,
"detailsPopup");
412 delete details_dialog;
421 GetStack(
"popup stack");
422 auto *showMenuPopup =
425 if (showMenuPopup->Create())
427 showMenuPopup->SetReturnEvent(
this,
"showMenuPopup");
429 showMenuPopup->AddButton(tr(
"Scan For Changes"));
435 showMenuPopup->AddButton(tr(
"Show Information"));
436 if (romInfo->Favorite())
437 showMenuPopup->AddButton(tr(
"Remove Favorite"));
439 showMenuPopup->AddButton(tr(
"Make Favorite"));
440 showMenuPopup->AddButton(tr(
"Retrieve Details"));
441 showMenuPopup->AddButton(tr(
"Edit Details"));
447 delete showMenuPopup;
454 if (parent !=
nullptr)
456 QStringList childList;
457 QList<MythGenericTree*>::iterator it;
460 for (it = children->begin(); it != children->end(); ++it)
469 tr(
"Game Search"), childList,
true,
"");
471 if (searchDialog->Create())
501 QString resultid = dce->
GetId();
502 QString resulttext = dce->GetResultText();
504 if (resultid ==
"showMenuPopup")
506 if (resulttext == tr(
"Edit Details"))
510 if (resulttext == tr(
"Scan For Changes"))
514 else if (resulttext == tr(
"Show Information"))
518 else if (resulttext == tr(
"Make Favorite") ||
519 resulttext == tr(
"Remove Favorite"))
523 else if (resulttext == tr(
"Retrieve Details"))
528 else if (resultid ==
"chooseSystemPopup")
530 if (!resulttext.isEmpty() && resulttext != tr(
"Cancel"))
537 else if (resultid ==
"editMetadata")
543 auto *romInfo = dce->GetData().value<
RomInfo *>();
544 node->
SetData(QVariant::fromValue(romInfo));
545 node->
SetText(romInfo->Gamename());
547 romInfo->SaveToDatabase();
550 else if (resultid ==
"detailsPopup")
572 if (lul.count() == 1)
578 auto *resultsdialog =
583 Qt::QueuedConnection);
585 if (resultsdialog->Create())
613 LOG(VB_GENERAL, LOG_ERR,
614 QString(
"No results found for %1").arg(lookup->
GetTitle()));
640 QString layer = node->
GetText();
641 int childDepth = node->
getInt() + 1;
647 if (childLevel.isEmpty())
648 childLevel =
"gamename";
651 QString conj =
"where ";
653 if (!filter.isEmpty())
655 filter = conj + filter;
660 columns = childIsLeaf
661 ?
"romname,`system`,year,genre,gamename"
665 filter +=
" and romname like '" + layer +
"%'";
668 else if ((childLevel ==
"gamename") && (layer.length() == 1))
670 columns = childIsLeaf
671 ? childLevel +
",`system`,year,genre,gamename"
675 filter +=
" and gamename like '" + layer +
"%'";
678 else if (childLevel ==
"hash")
680 columns =
"left(gamename,1)";
685 columns = childIsLeaf
686 ? childLevel +
",`system`,year,genre,gamename"
694 if (!romInfo->System().isEmpty())
696 filter += conj +
"trim(system)=:SYSTEM";
699 if (!romInfo->Year().isEmpty())
701 filter += conj +
"year=:YEAR";
704 if (!romInfo->Genre().isEmpty())
706 filter += conj +
"trim(genre)=:GENRE";
709 if (!romInfo->Plot().isEmpty())
711 filter += conj +
"plot=:PLOT";
714 if (!romInfo->Publisher().isEmpty())
716 filter += conj +
"publisher=:PUBLISHER";
719 if (!romInfo->Gamename().isEmpty())
721 filter += conj +
"trim(gamename)=:GAMENAME";
726 filter += conj +
" display = 1 ";
732 sql =
"select distinct "
734 +
" from gamemetadata "
736 +
" order by romname"
739 else if (childLevel ==
"hash")
741 sql =
"select distinct "
743 +
" from gamemetadata "
745 +
" order by gamename,romname"
750 sql =
"select distinct "
752 +
" from gamemetadata "
764 unsigned this_level = node->
getInt();
765 while (node->
getInt() != 1)
769 return gi->
getLevel(this_level - 1);
774 while (node->
getInt() != 1)
782 while (node->
getInt() != 1)
805 if (!romInfo->System().isEmpty())
806 query.bindValue(
":SYSTEM", romInfo->System());
807 if (!romInfo->Year().isEmpty())
808 query.bindValue(
":YEAR", romInfo->Year());
809 if (!romInfo->Genre().isEmpty())
810 query.bindValue(
":GENRE", romInfo->Genre());
811 if (!romInfo->Plot().isEmpty())
812 query.bindValue(
":PLOT", romInfo->Plot());
813 if (!romInfo->Publisher().isEmpty())
814 query.bindValue(
":PUBLISHER", romInfo->Publisher());
815 if (!romInfo->Gamename().isEmpty())
816 query.bindValue(
":GAMENAME", romInfo->Gamename());
820 if (query.exec() && query.size() > 0)
824 QString
current = query.value(0).toString().trimmed();
830 temp->setSystem(query.value(1).toString().trimmed());
831 temp->setYear(query.value(2).toString());
832 temp->setGenre(query.value(3).toString().trimmed());
833 temp->setGamename(query.value(4).toString().trimmed());
834 new_node->SetData(QVariant::fromValue(temp));
843 newRomInfo =
new RomInfo(*currentRomInfo);
849 new_node->SetData(QVariant::fromValue(newRomInfo));
866 QList<MythGenericTree*>::iterator it;
869 for (it = children->begin(); it != children->end(); ++it)
872 if (child != top_level)
908 lookup->SetData(QVariant::fromValue(node));
912 lookup->SetAutomatic(
true);
915 lookup->SetTitle(metadata->Gamename());
916 lookup->SetInetref(metadata->Inetref());
925 QString msg = tr(
"Fetching details for %1")
926 .arg(metadata->Gamename());
936 const QString& message = title;
939 "mythgamebusydialog");
975 metadata->setYear(QString::number(lookup->
GetYear()));
977 metadata->setSystem(lookup->
GetSystem());
979 QStringList coverart;
981 QStringList screenshot;
985 for (
const auto & art : qAsConst(coverartlist))
986 coverart.prepend(art.url);
988 for (
const auto & art : qAsConst(fanartlist))
989 fanart.prepend(art.url);
991 for (
const auto & art : qAsConst(screenshotlist))
992 screenshot.prepend(art.url);
996 metadata->SaveToDatabase();
1001 QStringList fanart, QStringList screenshot)
1012 if (metadata->Boxart().isEmpty() && !coverart.empty())
1015 info.
url = coverart.takeAt(0).trimmed();
1019 if (metadata->Fanart().isEmpty() && !fanart.empty())
1022 info.
url = fanart.takeAt(0).trimmed();
1026 if (metadata->Screenshot().isEmpty() && !screenshot.empty())
1029 info.
url = screenshot.takeAt(0).trimmed();
1034 lookup->SetTitle(metadata->Gamename());
1035 lookup->SetSystem(metadata->System());
1036 lookup->SetInetref(metadata->Inetref());
1038 lookup->SetDownloads(map);
1039 lookup->SetData(QVariant::fromValue(node));
1059 if (downloads.isEmpty())
1062 for (DownloadMap::iterator i = downloads.begin();
1063 i != downloads.end(); ++i)
1077 metadata->SaveToDatabase();
QString getFillSql(MythGenericTree *node) const
MythScreenStack * m_popupStack
static bool isLeaf(MythGenericTree *node)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
MythScreenStack * GetMainStack()
Q_DECLARE_METATYPE(GrabberScript *)
Provide a dialog to quickly find an entry in a list.
void customEvent(QEvent *event) override
static QString getChildLevelString(MythGenericTree *node)
void SetData(QVariant data)
GameTreeInfo(const QString &levels, QString filter)
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
QString GetText(const QString &name="") const
void createBusyDialog(const QString &title)
void ShowMenu(void) override
void nodeChanged(MythGenericTree *node)
MythUIText * m_gameYearText
void StartGameImageSet(MythGenericTree *node, QStringList coverart, QStringList fanart, QStringList screenshot)
const QString & getLevel(unsigned i) const
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
MythUIButtonTree * m_gameUITree
bool Create(void) override
QVariant GetData(void) const
MythGenericTree * getChildByName(const QString &a_name) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Screen in which all other widgets are contained and rendered.
void itemClicked(MythUIButtonListItem *item)
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
void Reset(void) override
Reset the image back to the default defined in the theme.
void searchComplete(const QString &string)
MythGenericTree * m_gameTree
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
static const QString sLocation
MythUIType * GetFocusWidget(void) const
MythUIText * m_gamePlotText
MythGenericTree * addNode(const QString &a_string, int an_int=0, bool selectable_flag=false, bool visible=true)
void updateChangedNode(MythGenericTree *node, RomInfo *romInfo)
QString Screenshot() const
MythUIImage * m_gameImage
void gameSearch(MythGenericTree *node=nullptr, bool automode=false)
void reloadAllData(bool dbchanged)
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
void setGamename(const QString &lgamename)
Basic menu dialog, message and a list of options.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
void OnGameSearchDone(MetadataLookup *lookup)
static GameHandler * getHandler(uint i)
void BuildFocusList(void)
int childCount(void) const
MythUIText * m_gameGenreText
void OnGameSearchListSelection(RefCountHandler< MetadataLookup > lookup)
void setFavorite(bool updateDatabase=false)
void handleDownloadedImages(MetadataLookup *lookup)
MythUIBusyDialog * m_busyPopup
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythScreenStack * GetScreenStack() const
QList< MythGenericTree * > * getAllChildren() const
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
bool GetBoolSetting(const QString &key, bool defaultval=false)
MythUIText * m_gameSystemText
MythUIText * m_gameTitleText
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
QString SystemName() const
MythUIImage * m_fanartImage
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythGenericTree * getParent(void) const
MetadataDownload * m_query
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
MetadataImageDownload * m_imageDownload
MythUIStateType * m_gameFavouriteState
virtual void SetText(const QString &text)
MythNotificationCenter * GetNotificationCenter(void)
MythMainWindow * GetMythMainWindow(void)
bool isRunning(void) const
static void Launchgame(RomInfo *romdata, const QString &systemname)
void resetOtherTrees(MythGenericTree *node)
MythGenericTree * m_favouriteNode
MythScreenStack * GetStack(const QString &Stackname)
static QString getFilter(MythGenericTree *node)
static int getLevelsOnThisBranch(MythGenericTree *node)
void SetText(const QString &text, const QString &name="", const QString &state="")
void setField(const QString &field, const QString &data)
const QString & getFilter() const
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
virtual int IncrRef(void)
Increments reference count.
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
void toggleFavorite(void)
void fillNode(MythGenericTree *node)
bool DisplayState(const QString &name)
QString GetSetting(const QString &key, const QString &defaultval="")
void updateRomInfo(RomInfo *rom)
bool Queue(const MythNotification ¬ification)
Queue a notification Queue() is thread-safe and can be called from anywhere.