Go to the documentation of this file.
75 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'gameui'");
106 QString systemFilter;
112 for (
unsigned i = 0; i < handlercount; ++i)
116 systemFilter =
"`system` in ('" + system +
"'";
118 systemFilter +=
",'" + system +
"'";
120 if (systemFilter.isEmpty())
122 systemFilter =
"1=0";
123 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find any game handlers!"));
139 new_node->SetData(QVariant::fromValue(
140 new GameTreeInfo(levels, systemFilter +
" and favorite=1")));
147 int pos = levels.indexOf(
"gamename");
149 levels.insert(pos,
" hash ");
153 new_node->SetData(QVariant::fromValue(
158 new_node->SetData(QVariant::fromValue(
163 new_node->SetData(QVariant::fromValue(
168 new_node->SetData(QVariant::fromValue(
173 new_node->SetData(QVariant::fromValue(
189 for (
int i = 0; i < actions.size() && !handled; i++)
191 const QString&
action = actions[i];
196 else if (
action ==
"EDIT")
198 else if (
action ==
"INFO")
200 else if (
action ==
"TOGGLEFAV")
202 else if ((
action ==
"INCSEARCH") || (
action ==
"INCSEARCHNEXT"))
204 else if (
action ==
"DOWNLOADDATA")
235 if (romInfo->Romname().isEmpty())
238 if (!romInfo->Screenshot().isEmpty() || !romInfo->Fanart().isEmpty() ||
239 !romInfo->Boxart().isEmpty())
261 if (romInfo->RomCount() == 1)
268 QString msg = tr(
"Choose System for:\n%1").arg(node->
GetText());
270 GetStack(
"popup stack");
272 msg, popupStack,
"chooseSystemPopup");
274 if (chooseSystemPopup->Create())
276 chooseSystemPopup->SetReturnEvent(
this,
"chooseSystemPopup");
277 QString all_systems = romInfo->AllSystems();
278 QStringList players = all_systems.split(
',');
279 for (
const auto & player : std::as_const(players))
280 chooseSystemPopup->AddButton(player);
281 popupStack->
AddScreen(chooseSystemPopup);
285 delete chooseSystemPopup;
388 "mythgameeditmetadata", romInfo);
390 if (md_editor->Create())
392 screenStack->AddScreen(md_editor);
393 md_editor->SetReturnEvent(
this,
"editMetadata");
413 if (details_dialog->Create())
416 details_dialog->SetReturnEvent(
this,
"detailsPopup");
420 delete details_dialog;
430 GetStack(
"popup stack");
431 auto *showMenuPopup =
434 if (showMenuPopup->Create())
436 showMenuPopup->SetReturnEvent(
this,
"showMenuPopup");
438 showMenuPopup->AddButton(tr(
"Scan For Changes"));
444 showMenuPopup->AddButton(tr(
"Show Information"));
445 if (romInfo->Favorite())
446 showMenuPopup->AddButton(tr(
"Remove Favorite"));
448 showMenuPopup->AddButton(tr(
"Make Favorite"));
449 showMenuPopup->AddButton(tr(
"Retrieve Details"));
450 showMenuPopup->AddButton(tr(
"Edit Details"));
457 delete showMenuPopup;
465 if (parent !=
nullptr)
467 QStringList childList;
468 QList<MythGenericTree*>::iterator it;
471 for (it = children->begin(); it != children->end(); ++it)
480 tr(
"Game Search"), childList,
true,
"");
482 if (searchDialog->Create())
514 QString resultid = dce->
GetId();
515 QString resulttext = dce->GetResultText();
517 if (resultid ==
"showMenuPopup")
519 if (resulttext == tr(
"Edit Details"))
523 if (resulttext == tr(
"Scan For Changes"))
527 else if (resulttext == tr(
"Show Information"))
531 else if (resulttext == tr(
"Make Favorite") ||
532 resulttext == tr(
"Remove Favorite"))
536 else if (resulttext == tr(
"Retrieve Details"))
541 else if (resultid ==
"chooseSystemPopup")
543 if (!resulttext.isEmpty() && resulttext != tr(
"Cancel"))
550 else if (resultid ==
"editMetadata")
556 auto *romInfo = dce->GetData().value<
RomInfo *>();
557 node->
SetData(QVariant::fromValue(romInfo));
558 node->
SetText(romInfo->Gamename());
560 romInfo->SaveToDatabase();
563 else if (resultid ==
"detailsPopup")
585 if (lul.count() == 1)
591 auto *resultsdialog =
596 Qt::QueuedConnection);
598 if (resultsdialog->Create())
626 LOG(VB_GENERAL, LOG_ERR,
627 QString(
"No results found for %1").arg(lookup->
GetTitle()));
653 QString layer = node->
GetText();
654 int childDepth = node->
getInt() + 1;
660 if (childLevel.isEmpty())
661 childLevel =
"gamename";
664 QString conj =
"where ";
666 if (!filter.isEmpty())
668 filter = conj + filter;
673 columns = childIsLeaf
674 ?
"romname,`system`,year,genre,gamename"
678 filter +=
" and romname like '" + layer +
"%'";
681 else if ((childLevel ==
"gamename") && (layer.length() == 1))
683 columns = childIsLeaf
684 ? childLevel +
",`system`,year,genre,gamename"
688 filter +=
" and gamename like '" + layer +
"%'";
691 else if (childLevel ==
"hash")
693 columns =
"left(gamename,1)";
698 columns = childIsLeaf
699 ? childLevel +
",`system`,year,genre,gamename"
707 if (!romInfo->System().isEmpty())
709 filter += conj +
"trim(system)=:SYSTEM";
712 if (!romInfo->Year().isEmpty())
714 filter += conj +
"year=:YEAR";
717 if (!romInfo->Genre().isEmpty())
719 filter += conj +
"trim(genre)=:GENRE";
722 if (!romInfo->Plot().isEmpty())
724 filter += conj +
"plot=:PLOT";
727 if (!romInfo->Publisher().isEmpty())
729 filter += conj +
"publisher=:PUBLISHER";
732 if (!romInfo->Gamename().isEmpty())
734 filter += conj +
"trim(gamename)=:GAMENAME";
739 filter += conj +
" display = 1 ";
745 sql =
"select distinct "
747 +
" from gamemetadata "
749 +
" order by romname"
752 else if (childLevel ==
"hash")
754 sql =
"select distinct "
756 +
" from gamemetadata "
758 +
" order by gamename,romname"
763 sql =
"select distinct "
765 +
" from gamemetadata "
777 unsigned this_level = node->
getInt();
778 while (node->
getInt() != 1)
782 return gi ? gi->
getLevel(this_level - 1) :
"<invalid>";
787 while (node->
getInt() != 1)
790 return gi ? gi->
getFilter() :
"<invalid>";
795 while (node->
getInt() != 1)
818 if (!romInfo->System().isEmpty())
819 query.bindValue(
":SYSTEM", romInfo->System());
820 if (!romInfo->Year().isEmpty())
821 query.bindValue(
":YEAR", romInfo->Year());
822 if (!romInfo->Genre().isEmpty())
823 query.bindValue(
":GENRE", romInfo->Genre());
824 if (!romInfo->Plot().isEmpty())
825 query.bindValue(
":PLOT", romInfo->Plot());
826 if (!romInfo->Publisher().isEmpty())
827 query.bindValue(
":PUBLISHER", romInfo->Publisher());
828 if (!romInfo->Gamename().isEmpty())
829 query.bindValue(
":GAMENAME", romInfo->Gamename());
833 if (query.exec() && query.size() > 0)
837 QString
current = query.value(0).toString().trimmed();
843 temp->setSystem(query.value(1).toString().trimmed());
844 temp->setYear(query.value(2).toString());
845 temp->setGenre(query.value(3).toString().trimmed());
846 temp->setGamename(query.value(4).toString().trimmed());
847 new_node->SetData(QVariant::fromValue(temp));
856 newRomInfo =
new RomInfo(*currentRomInfo);
862 new_node->SetData(QVariant::fromValue(newRomInfo));
879 QList<MythGenericTree*>::iterator it;
882 for (it = children->begin(); it != children->end(); ++it)
885 if (child != top_level)
923 lookup->SetData(QVariant::fromValue(node));
927 lookup->SetAutomatic(
true);
930 lookup->SetTitle(metadata->Gamename());
931 lookup->SetInetref(metadata->Inetref());
940 QString msg = tr(
"Fetching details for %1")
941 .arg(metadata->Gamename());
951 const QString& message = title;
954 "mythgamebusydialog");
990 metadata->setYear(QString::number(lookup->
GetYear()));
992 metadata->setSystem(lookup->
GetSystem());
994 QStringList coverart;
996 QStringList screenshot;
1000 for (
const auto & art : std::as_const(coverartlist))
1001 coverart.prepend(art.url);
1003 for (
const auto & art : std::as_const(fanartlist))
1004 fanart.prepend(art.url);
1006 for (
const auto & art : std::as_const(screenshotlist))
1007 screenshot.prepend(art.url);
1011 metadata->SaveToDatabase();
1016 QStringList fanart, QStringList screenshot)
1027 if (metadata->Boxart().isEmpty() && !coverart.empty())
1030 info.url = coverart.takeAt(0).trimmed();
1034 if (metadata->Fanart().isEmpty() && !fanart.empty())
1037 info.url = fanart.takeAt(0).trimmed();
1041 if (metadata->Screenshot().isEmpty() && !screenshot.empty())
1044 info.url = screenshot.takeAt(0).trimmed();
1049 lookup->SetTitle(metadata->Gamename());
1050 lookup->SetSystem(metadata->System());
1051 lookup->SetInetref(metadata->Inetref());
1053 lookup->SetDownloads(map);
1054 lookup->SetData(QVariant::fromValue(node));
1074 if (downloads.isEmpty())
1077 for (DownloadMap::iterator i = downloads.begin();
1078 i != downloads.end(); ++i)
1092 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()
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)
Q_DECLARE_METATYPE(std::chrono::seconds)
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 const Type kEventType
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)
static const Type kEventType
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)
static const Type kEventType
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.