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;
648 QString conj =
"where ";
650 if (!filter.isEmpty())
652 filter = conj + filter;
657 columns = childIsLeaf
658 ?
"romname,`system`,year,genre,gamename"
662 filter +=
" and romname like '" + layer +
"%'";
665 else if ((childLevel ==
"gamename") && (layer.length() == 1))
667 columns = childIsLeaf
668 ? childLevel +
",`system`,year,genre,gamename"
672 filter +=
" and gamename like '" + layer +
"%'";
675 else if (childLevel ==
"hash")
677 columns =
"left(gamename,1)";
682 columns = childIsLeaf
683 ? childLevel +
",`system`,year,genre,gamename"
691 if (!romInfo->System().isEmpty())
693 filter += conj +
"trim(system)=:SYSTEM";
696 if (!romInfo->Year().isEmpty())
698 filter += conj +
"year=:YEAR";
701 if (!romInfo->Genre().isEmpty())
703 filter += conj +
"trim(genre)=:GENRE";
706 if (!romInfo->Plot().isEmpty())
708 filter += conj +
"plot=:PLOT";
711 if (!romInfo->Publisher().isEmpty())
713 filter += conj +
"publisher=:PUBLISHER";
716 if (!romInfo->Gamename().isEmpty())
718 filter += conj +
"trim(gamename)=:GAMENAME";
723 filter += conj +
" display = 1 ";
729 sql =
"select distinct "
731 +
" from gamemetadata "
733 +
" order by romname"
736 else if (childLevel ==
"hash")
738 sql =
"select distinct "
740 +
" from gamemetadata "
742 +
" order by gamename,romname"
747 sql =
"select distinct "
749 +
" from gamemetadata "
761 unsigned this_level = node->
getInt();
762 while (node->
getInt() != 1)
766 return gi->
getLevel(this_level - 1);
771 while (node->
getInt() != 1)
779 while (node->
getInt() != 1)
802 if (!romInfo->System().isEmpty())
804 if (!romInfo->Year().isEmpty())
806 if (!romInfo->Genre().isEmpty())
808 if (!romInfo->Plot().isEmpty())
810 if (!romInfo->Publisher().isEmpty())
812 if (!romInfo->Gamename().isEmpty())
827 temp->setSystem(
query.
value(1).toString().trimmed());
829 temp->setGenre(
query.
value(3).toString().trimmed());
830 temp->setGamename(
query.
value(4).toString().trimmed());
831 new_node->SetData(QVariant::fromValue(temp));
840 newRomInfo =
new RomInfo(*currentRomInfo);
846 new_node->SetData(QVariant::fromValue(newRomInfo));
863 QList<MythGenericTree*>::iterator it;
866 for (it = children->begin(); it != children->end(); ++it)
869 if (child != top_level)
905 lookup->SetData(QVariant::fromValue(node));
909 lookup->SetAutomatic(
true);
912 lookup->SetTitle(metadata->Gamename());
913 lookup->SetInetref(metadata->Inetref());
922 QString msg = tr(
"Fetching details for %1")
923 .arg(metadata->Gamename());
933 const QString& message =
title;
936 "mythgamebusydialog");
972 metadata->setYear(QString::number(lookup->
GetYear()));
974 metadata->setSystem(lookup->
GetSystem());
976 QStringList coverart;
978 QStringList screenshot;
982 for (
const auto & art : qAsConst(coverartlist))
983 coverart.prepend(art.url);
985 for (
const auto & art : qAsConst(fanartlist))
986 fanart.prepend(art.url);
988 for (
const auto & art : qAsConst(screenshotlist))
989 screenshot.prepend(art.url);
993 metadata->SaveToDatabase();
998 QStringList fanart, QStringList screenshot)
1009 if (metadata->Boxart().isEmpty() && !coverart.empty())
1012 info.
url = coverart.takeAt(0).trimmed();
1016 if (metadata->Fanart().isEmpty() && !fanart.empty())
1019 info.
url = fanart.takeAt(0).trimmed();
1023 if (metadata->Screenshot().isEmpty() && !screenshot.empty())
1026 info.
url = screenshot.takeAt(0).trimmed();
1031 lookup->SetTitle(metadata->Gamename());
1032 lookup->SetSystem(metadata->System());
1033 lookup->SetInetref(metadata->Inetref());
1035 lookup->SetDownloads(map);
1036 lookup->SetData(QVariant::fromValue(node));
1056 if (downloads.isEmpty())
1059 for (DownloadMap::iterator i = downloads.begin();
1060 i != downloads.end(); ++i)
1074 metadata->SaveToDatabase();
QString getFillSql(MythGenericTree *node) const
MythScreenStack * m_popupStack
static bool isLeaf(MythGenericTree *node)
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
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 value(int i) const
arg(title).arg(filename).arg(doDelete))
QVariant GetData(void) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
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
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
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)
MSqlQuery query(MSqlQuery::InitCon())
void toggleFavorite(void)
void fillNode(MythGenericTree *node)
bool DisplayState(const QString &name)
QString GetSetting(const QString &key, const QString &defaultval="")
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
void updateRomInfo(RomInfo *rom)
bool Queue(const MythNotification ¬ification)
Queue a notification Queue() is thread-safe and can be called from anywhere.