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!"));
140 new_node->SetData(QVariant::fromValue(
141 new GameTreeInfo(levels, systemFilter +
" and favorite=1")));
148 int pos = levels.indexOf(
"gamename");
150 levels.insert(pos,
" hash ");
154 new_node->SetData(QVariant::fromValue(
159 new_node->SetData(QVariant::fromValue(
164 new_node->SetData(QVariant::fromValue(
169 new_node->SetData(QVariant::fromValue(
174 new_node->SetData(QVariant::fromValue(
190 for (
int i = 0; i < actions.size() && !handled; i++)
192 const QString&
action = actions[i];
197 else if (
action ==
"EDIT")
199 else if (
action ==
"INFO")
201 else if (
action ==
"TOGGLEFAV")
203 else if ((
action ==
"INCSEARCH") || (
action ==
"INCSEARCHNEXT"))
205 else if (
action ==
"DOWNLOADDATA")
236 if (romInfo->Romname().isEmpty())
239 if (!romInfo->Screenshot().isEmpty() || !romInfo->Fanart().isEmpty() ||
240 !romInfo->Boxart().isEmpty())
262 if (romInfo->RomCount() == 1)
269 QString msg = tr(
"Choose System for:\n%1").arg(node->
GetText());
271 GetStack(
"popup stack");
273 msg, popupStack,
"chooseSystemPopup");
275 if (chooseSystemPopup->Create())
277 chooseSystemPopup->SetReturnEvent(
this,
"chooseSystemPopup");
278 QString all_systems = romInfo->AllSystems();
279 QStringList players = all_systems.split(
',');
280 for (
const auto & player : std::as_const(players))
281 chooseSystemPopup->AddButton(player);
282 popupStack->
AddScreen(chooseSystemPopup);
286 delete chooseSystemPopup;
389 "mythgameeditmetadata", romInfo);
391 if (md_editor->Create())
393 screenStack->AddScreen(md_editor);
394 md_editor->SetReturnEvent(
this,
"editMetadata");
414 if (details_dialog->Create())
417 details_dialog->SetReturnEvent(
this,
"detailsPopup");
421 delete details_dialog;
431 GetStack(
"popup stack");
432 auto *showMenuPopup =
435 if (showMenuPopup->Create())
437 showMenuPopup->SetReturnEvent(
this,
"showMenuPopup");
439 showMenuPopup->AddButton(tr(
"Scan For Changes"));
445 showMenuPopup->AddButton(tr(
"Show Information"));
446 if (romInfo->Favorite())
447 showMenuPopup->AddButton(tr(
"Remove Favorite"));
449 showMenuPopup->AddButton(tr(
"Make Favorite"));
450 showMenuPopup->AddButton(tr(
"Retrieve Details"));
451 showMenuPopup->AddButton(tr(
"Edit Details"));
458 delete showMenuPopup;
466 if (parent !=
nullptr)
468 QStringList childList;
469 QList<MythGenericTree*>::iterator it;
472 for (it = children->begin(); it != children->end(); ++it)
481 tr(
"Game Search"), childList,
true,
"");
483 if (searchDialog->Create())
515 QString resultid = dce->
GetId();
516 QString resulttext = dce->GetResultText();
518 if (resultid ==
"showMenuPopup")
520 if (resulttext == tr(
"Edit Details"))
524 if (resulttext == tr(
"Scan For Changes"))
528 else if (resulttext == tr(
"Show Information"))
532 else if (resulttext == tr(
"Make Favorite") ||
533 resulttext == tr(
"Remove Favorite"))
537 else if (resulttext == tr(
"Retrieve Details"))
542 else if (resultid ==
"chooseSystemPopup")
544 if (!resulttext.isEmpty() && resulttext != tr(
"Cancel"))
551 else if (resultid ==
"editMetadata")
557 auto *romInfo = dce->GetData().value<
RomInfo *>();
558 node->
SetData(QVariant::fromValue(romInfo));
559 node->
SetText(romInfo->Gamename());
561 romInfo->SaveToDatabase();
564 else if (resultid ==
"detailsPopup")
586 if (lul.count() == 1)
592 auto *resultsdialog =
597 Qt::QueuedConnection);
599 if (resultsdialog->Create())
627 LOG(VB_GENERAL, LOG_ERR,
628 QString(
"No results found for %1").arg(lookup->
GetTitle()));
654 QString layer = node->
GetText();
655 int childDepth = node->
getInt() + 1;
661 if (childLevel.isEmpty())
662 childLevel =
"gamename";
665 QString conj =
"where ";
667 if (!filter.isEmpty())
669 filter = conj + filter;
674 columns = childIsLeaf
675 ?
"romname,`system`,year,genre,gamename"
679 filter +=
" and romname like '" + layer +
"%'";
682 else if ((childLevel ==
"gamename") && (layer.length() == 1))
684 columns = childIsLeaf
685 ? childLevel +
",`system`,year,genre,gamename"
689 filter +=
" and gamename like '" + layer +
"%'";
692 else if (childLevel ==
"hash")
694 columns =
"left(gamename,1)";
699 columns = childIsLeaf
700 ? childLevel +
",`system`,year,genre,gamename"
708 if (!romInfo->System().isEmpty())
710 filter += conj +
"trim(system)=:SYSTEM";
713 if (!romInfo->Year().isEmpty())
715 filter += conj +
"year=:YEAR";
718 if (!romInfo->Genre().isEmpty())
720 filter += conj +
"trim(genre)=:GENRE";
723 if (!romInfo->Plot().isEmpty())
725 filter += conj +
"plot=:PLOT";
728 if (!romInfo->Publisher().isEmpty())
730 filter += conj +
"publisher=:PUBLISHER";
733 if (!romInfo->Gamename().isEmpty())
735 filter += conj +
"trim(gamename)=:GAMENAME";
740 filter += conj +
" display = 1 ";
746 sql =
"select distinct "
748 +
" from gamemetadata "
750 +
" order by romname"
753 else if (childLevel ==
"hash")
755 sql =
"select distinct "
757 +
" from gamemetadata "
759 +
" order by gamename,romname"
764 sql =
"select distinct "
766 +
" from gamemetadata "
778 unsigned this_level = node->
getInt();
779 while (node->
getInt() != 1)
783 return gi ? gi->
getLevel(this_level - 1) :
"<invalid>";
788 while (node->
getInt() != 1)
791 return gi ? gi->
getFilter() :
"<invalid>";
796 while (node->
getInt() != 1)
819 if (!romInfo->System().isEmpty())
820 query.bindValue(
":SYSTEM", romInfo->System());
821 if (!romInfo->Year().isEmpty())
822 query.bindValue(
":YEAR", romInfo->Year());
823 if (!romInfo->Genre().isEmpty())
824 query.bindValue(
":GENRE", romInfo->Genre());
825 if (!romInfo->Plot().isEmpty())
826 query.bindValue(
":PLOT", romInfo->Plot());
827 if (!romInfo->Publisher().isEmpty())
828 query.bindValue(
":PUBLISHER", romInfo->Publisher());
829 if (!romInfo->Gamename().isEmpty())
830 query.bindValue(
":GAMENAME", romInfo->Gamename());
834 if (query.exec() && query.size() > 0)
838 QString
current = query.value(0).toString().trimmed();
844 temp->setSystem(query.value(1).toString().trimmed());
845 temp->setYear(query.value(2).toString());
846 temp->setGenre(query.value(3).toString().trimmed());
847 temp->setGamename(query.value(4).toString().trimmed());
848 new_node->SetData(QVariant::fromValue(temp));
857 newRomInfo =
new RomInfo(*currentRomInfo);
863 new_node->SetData(QVariant::fromValue(newRomInfo));
880 QList<MythGenericTree*>::iterator it;
883 for (it = children->begin(); it != children->end(); ++it)
886 if (child != top_level)
924 lookup->SetData(QVariant::fromValue(node));
928 lookup->SetAutomatic(
true);
931 lookup->SetTitle(metadata->Gamename());
932 lookup->SetInetref(metadata->Inetref());
941 QString msg = tr(
"Fetching details for %1")
942 .arg(metadata->Gamename());
952 const QString& message = title;
955 "mythgamebusydialog");
991 metadata->setYear(QString::number(lookup->
GetYear()));
993 metadata->setSystem(lookup->
GetSystem());
995 QStringList coverart;
997 QStringList screenshot;
1001 for (
const auto & art : std::as_const(coverartlist))
1002 coverart.prepend(art.url);
1004 for (
const auto & art : std::as_const(fanartlist))
1005 fanart.prepend(art.url);
1007 for (
const auto & art : std::as_const(screenshotlist))
1008 screenshot.prepend(art.url);
1012 metadata->SaveToDatabase();
1017 QStringList fanart, QStringList screenshot)
1028 if (metadata->Boxart().isEmpty() && !coverart.empty())
1031 info.url = coverart.takeAt(0).trimmed();
1035 if (metadata->Fanart().isEmpty() && !fanart.empty())
1038 info.url = fanart.takeAt(0).trimmed();
1042 if (metadata->Screenshot().isEmpty() && !screenshot.empty())
1045 info.url = screenshot.takeAt(0).trimmed();
1050 lookup->SetTitle(metadata->Gamename());
1051 lookup->SetSystem(metadata->System());
1052 lookup->SetInetref(metadata->Inetref());
1054 lookup->SetDownloads(map);
1055 lookup->SetData(QVariant::fromValue(node));
1075 if (downloads.isEmpty())
1078 for (DownloadMap::iterator i = downloads.begin();
1079 i != downloads.end(); ++i)
1093 metadata->SaveToDatabase();
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
static const Type kEventType
static GameHandler * getHandler(uint i)
QString SystemName() const
static void Launchgame(RomInfo *romdata, const QString &systemname)
const QString & getFilter() const
const QString & getLevel(unsigned i) const
GameTreeInfo(const QString &levels, QString filter)
static bool isLeaf(MythGenericTree *node)
MythUIButtonTree * m_gameUITree
void OnGameSearchListSelection(RefCountHandler< MetadataLookup > lookup)
MetadataDownload * m_query
void reloadAllData(bool dbchanged)
MythUIStateType * m_gameFavouriteState
MythUIBusyDialog * m_busyPopup
void nodeChanged(MythGenericTree *node)
static QString getChildLevelString(MythGenericTree *node)
void fillNode(MythGenericTree *node)
MythUIText * m_gamePlotText
void gameSearch(MythGenericTree *node=nullptr, bool automode=false)
MythUIText * m_gameSystemText
void updateChangedNode(MythGenericTree *node, RomInfo *romInfo)
MythUIText * m_gameYearText
void StartGameImageSet(MythGenericTree *node, QStringList coverart, QStringList fanart, QStringList screenshot)
MythUIText * m_gameTitleText
void createBusyDialog(const QString &title)
MythUIText * m_gameGenreText
static int getLevelsOnThisBranch(MythGenericTree *node)
QString getFillSql(MythGenericTree *node) const
MythScreenStack * m_popupStack
void searchComplete(const QString &string)
MetadataImageDownload * m_imageDownload
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
static QString getFilter(MythGenericTree *node)
void toggleFavorite(void)
void customEvent(QEvent *event) override
void ShowMenu(void) override
MythGenericTree * m_favouriteNode
void resetOtherTrees(MythGenericTree *node)
MythUIImage * m_fanartImage
void itemClicked(MythUIButtonListItem *item)
MythGenericTree * m_gameTree
void OnGameSearchDone(MetadataLookup *lookup)
void handleDownloadedImages(MetadataLookup *lookup)
MythUIImage * m_gameImage
void updateRomInfo(RomInfo *rom)
static const Type kEventType
static const Type kEventType
QSqlQuery wrapper that fetches a DB connection from the connection pool.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
bool isRunning(void) const
QString GetSetting(const QString &key, const QString &defaultval="")
bool GetBoolSetting(const QString &key, bool defaultval=false)
Basic menu dialog, message and a list of options.
QVariant GetData(void) const
QString GetText(const QString &name="") const
MythGenericTree * getParent(void) const
void SetText(const QString &text, const QString &name="", const QString &state="")
MythGenericTree * addNode(const QString &a_string, int an_int=0, bool selectable_flag=false, bool visible=true)
int childCount(void) const
MythGenericTree * getChildByName(const QString &a_name) const
void SetData(QVariant data)
QList< MythGenericTree * > * getAllChildren() const
MythScreenStack * GetMainStack()
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythScreenStack * GetStack(const QString &Stackname)
bool Queue(const MythNotification ¬ification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
MythScreenStack * GetScreenStack() const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool Create(void) override
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
void Reset(void) override
Reset the image back to the default defined in the theme.
Provide a dialog to quickly find an entry in a list.
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
bool DisplayState(const QString &name)
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
virtual void SetText(const QString &text)
QString Screenshot() const
void setFavorite(bool updateDatabase=false)
void setField(const QString &field, const QString &data)
void setGamename(const QString &lgamename)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
static const QString sLocation
Q_DECLARE_METATYPE(std::chrono::seconds)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythNotificationCenter * GetNotificationCenter(void)
MythMainWindow * GetMythMainWindow(void)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)