Go to the documentation of this file.
76 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'gameui'");
107 QString systemFilter;
113 for (
unsigned i = 0; i < handlercount; ++i)
117 systemFilter =
"`system` in ('" + system +
"'";
119 systemFilter +=
",'" + system +
"'";
121 if (systemFilter.isEmpty())
123 systemFilter =
"1=0";
124 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find any game handlers!"));
138 new_node->SetData(QVariant::fromValue(
139 new GameTreeInfo(levels, systemFilter +
" and favorite=1")));
146 int pos = levels.indexOf(
"gamename");
148 levels.insert(pos,
" hash ");
152 new_node->SetData(QVariant::fromValue(
157 new_node->SetData(QVariant::fromValue(
162 new_node->SetData(QVariant::fromValue(
167 new_node->SetData(QVariant::fromValue(
172 new_node->SetData(QVariant::fromValue(
188 for (
int i = 0; i < actions.size() && !handled; i++)
190 QString
action = actions[i];
195 else if (
action ==
"EDIT")
197 else if (
action ==
"INFO")
199 else if (
action ==
"TOGGLEFAV")
201 else if ((
action ==
"INCSEARCH") || (
action ==
"INCSEARCHNEXT"))
203 else if (
action ==
"DOWNLOADDATA")
234 if (romInfo->Romname().isEmpty())
237 if (!romInfo->Screenshot().isEmpty() || !romInfo->Fanart().isEmpty() ||
238 !romInfo->Boxart().isEmpty())
260 if (romInfo->RomCount() == 1)
267 QString msg = tr(
"Choose System for:\n%1").arg(node->
GetText());
269 GetStack(
"popup stack");
271 msg, popupStack,
"chooseSystemPopup");
273 if (chooseSystemPopup->Create())
275 chooseSystemPopup->SetReturnEvent(
this,
"chooseSystemPopup");
276 QString all_systems = romInfo->AllSystems();
277 QStringList players = all_systems.split(
',');
278 for (
const auto & player : qAsConst(players))
279 chooseSystemPopup->AddButton(player);
280 popupStack->
AddScreen(chooseSystemPopup);
283 delete chooseSystemPopup;
385 "mythgameeditmetadata", romInfo);
387 if (md_editor->Create())
389 screenStack->AddScreen(md_editor);
390 md_editor->SetReturnEvent(
this,
"editMetadata");
408 if (details_dialog->Create())
411 details_dialog->SetReturnEvent(
this,
"detailsPopup");
414 delete details_dialog;
423 GetStack(
"popup stack");
424 auto *showMenuPopup =
427 if (showMenuPopup->Create())
429 showMenuPopup->SetReturnEvent(
this,
"showMenuPopup");
431 showMenuPopup->AddButton(tr(
"Scan For Changes"));
437 showMenuPopup->AddButton(tr(
"Show Information"));
438 if (romInfo->Favorite())
439 showMenuPopup->AddButton(tr(
"Remove Favorite"));
441 showMenuPopup->AddButton(tr(
"Make Favorite"));
442 showMenuPopup->AddButton(tr(
"Retrieve Details"));
443 showMenuPopup->AddButton(tr(
"Edit Details"));
449 delete showMenuPopup;
456 if (parent !=
nullptr)
458 QStringList childList;
459 QList<MythGenericTree*>::iterator it;
462 for (it = children->begin(); it != children->end(); ++it)
471 tr(
"Game Search"), childList,
true,
"");
473 if (searchDialog->Create())
503 QString resultid = dce->
GetId();
504 QString resulttext = dce->GetResultText();
506 if (resultid ==
"showMenuPopup")
508 if (resulttext == tr(
"Edit Details"))
512 if (resulttext == tr(
"Scan For Changes"))
516 else if (resulttext == tr(
"Show Information"))
520 else if (resulttext == tr(
"Make Favorite") ||
521 resulttext == tr(
"Remove Favorite"))
525 else if (resulttext == tr(
"Retrieve Details"))
530 else if (resultid ==
"chooseSystemPopup")
532 if (!resulttext.isEmpty() && resulttext != tr(
"Cancel"))
539 else if (resultid ==
"editMetadata")
545 auto *romInfo = dce->GetData().value<
RomInfo *>();
546 node->
SetData(QVariant::fromValue(romInfo));
547 node->
SetText(romInfo->Gamename());
549 romInfo->SaveToDatabase();
552 else if (resultid ==
"detailsPopup")
574 if (lul.count() == 1)
580 auto *resultsdialog =
585 Qt::QueuedConnection);
587 if (resultsdialog->Create())
615 LOG(VB_GENERAL, LOG_ERR,
616 QString(
"No results found for %1").arg(lookup->
GetTitle()));
642 QString layer = node->
GetText();
643 int childDepth = node->
getInt() + 1;
649 if (childLevel.isEmpty())
650 childLevel =
"gamename";
653 QString conj =
"where ";
655 if (!filter.isEmpty())
657 filter = conj + filter;
662 columns = childIsLeaf
663 ?
"romname,`system`,year,genre,gamename"
667 filter +=
" and romname like '" + layer +
"%'";
670 else if ((childLevel ==
"gamename") && (layer.length() == 1))
672 columns = childIsLeaf
673 ? childLevel +
",`system`,year,genre,gamename"
677 filter +=
" and gamename like '" + layer +
"%'";
680 else if (childLevel ==
"hash")
682 columns =
"left(gamename,1)";
687 columns = childIsLeaf
688 ? childLevel +
",`system`,year,genre,gamename"
696 if (!romInfo->System().isEmpty())
698 filter += conj +
"trim(system)=:SYSTEM";
701 if (!romInfo->Year().isEmpty())
703 filter += conj +
"year=:YEAR";
706 if (!romInfo->Genre().isEmpty())
708 filter += conj +
"trim(genre)=:GENRE";
711 if (!romInfo->Plot().isEmpty())
713 filter += conj +
"plot=:PLOT";
716 if (!romInfo->Publisher().isEmpty())
718 filter += conj +
"publisher=:PUBLISHER";
721 if (!romInfo->Gamename().isEmpty())
723 filter += conj +
"trim(gamename)=:GAMENAME";
728 filter += conj +
" display = 1 ";
734 sql =
"select distinct "
736 +
" from gamemetadata "
738 +
" order by romname"
741 else if (childLevel ==
"hash")
743 sql =
"select distinct "
745 +
" from gamemetadata "
747 +
" order by gamename,romname"
752 sql =
"select distinct "
754 +
" from gamemetadata "
766 unsigned this_level = node->
getInt();
767 while (node->
getInt() != 1)
771 return gi->
getLevel(this_level - 1);
776 while (node->
getInt() != 1)
784 while (node->
getInt() != 1)
807 if (!romInfo->System().isEmpty())
808 query.bindValue(
":SYSTEM", romInfo->System());
809 if (!romInfo->Year().isEmpty())
810 query.bindValue(
":YEAR", romInfo->Year());
811 if (!romInfo->Genre().isEmpty())
812 query.bindValue(
":GENRE", romInfo->Genre());
813 if (!romInfo->Plot().isEmpty())
814 query.bindValue(
":PLOT", romInfo->Plot());
815 if (!romInfo->Publisher().isEmpty())
816 query.bindValue(
":PUBLISHER", romInfo->Publisher());
817 if (!romInfo->Gamename().isEmpty())
818 query.bindValue(
":GAMENAME", romInfo->Gamename());
822 if (query.exec() && query.size() > 0)
826 QString
current = query.value(0).toString().trimmed();
832 temp->setSystem(query.value(1).toString().trimmed());
833 temp->setYear(query.value(2).toString());
834 temp->setGenre(query.value(3).toString().trimmed());
835 temp->setGamename(query.value(4).toString().trimmed());
836 new_node->SetData(QVariant::fromValue(temp));
845 newRomInfo =
new RomInfo(*currentRomInfo);
851 new_node->SetData(QVariant::fromValue(newRomInfo));
868 QList<MythGenericTree*>::iterator it;
871 for (it = children->begin(); it != children->end(); ++it)
874 if (child != top_level)
910 lookup->SetData(QVariant::fromValue(node));
914 lookup->SetAutomatic(
true);
917 lookup->SetTitle(metadata->Gamename());
918 lookup->SetInetref(metadata->Inetref());
927 QString msg = tr(
"Fetching details for %1")
928 .arg(metadata->Gamename());
938 const QString& message = title;
941 "mythgamebusydialog");
977 metadata->setYear(QString::number(lookup->
GetYear()));
979 metadata->setSystem(lookup->
GetSystem());
981 QStringList coverart;
983 QStringList screenshot;
987 for (
const auto & art : qAsConst(coverartlist))
988 coverart.prepend(art.url);
990 for (
const auto & art : qAsConst(fanartlist))
991 fanart.prepend(art.url);
993 for (
const auto & art : qAsConst(screenshotlist))
994 screenshot.prepend(art.url);
998 metadata->SaveToDatabase();
1003 QStringList fanart, QStringList screenshot)
1014 if (metadata->Boxart().isEmpty() && !coverart.empty())
1017 info.
url = coverart.takeAt(0).trimmed();
1021 if (metadata->Fanart().isEmpty() && !fanart.empty())
1024 info.
url = fanart.takeAt(0).trimmed();
1028 if (metadata->Screenshot().isEmpty() && !screenshot.empty())
1031 info.
url = screenshot.takeAt(0).trimmed();
1036 lookup->SetTitle(metadata->Gamename());
1037 lookup->SetSystem(metadata->System());
1038 lookup->SetInetref(metadata->Inetref());
1040 lookup->SetDownloads(map);
1041 lookup->SetData(QVariant::fromValue(node));
1061 if (downloads.isEmpty())
1064 for (DownloadMap::iterator i = downloads.begin();
1065 i != downloads.end(); ++i)
1079 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
Q_DECLARE_METATYPE(StandardSetting *)
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 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.