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())
264 if (romInfo->RomCount() == 1)
271 QString msg = tr(
"Choose System for:\n%1").arg(node->
GetText());
273 GetStack(
"popup stack");
275 msg, popupStack,
"chooseSystemPopup");
277 if (chooseSystemPopup->Create())
279 chooseSystemPopup->SetReturnEvent(
this,
"chooseSystemPopup");
280 QString all_systems = romInfo->AllSystems();
281 QStringList players = all_systems.split(
',');
282 for (
const auto & player : std::as_const(players))
283 chooseSystemPopup->AddButton(player);
284 popupStack->
AddScreen(chooseSystemPopup);
288 delete chooseSystemPopup;
391 "mythgameeditmetadata", romInfo);
393 if (md_editor->Create())
395 screenStack->AddScreen(md_editor);
396 md_editor->SetReturnEvent(
this,
"editMetadata");
416 if (details_dialog->Create())
419 details_dialog->SetReturnEvent(
this,
"detailsPopup");
423 delete details_dialog;
433 GetStack(
"popup stack");
434 auto *showMenuPopup =
437 if (showMenuPopup->Create())
439 showMenuPopup->SetReturnEvent(
this,
"showMenuPopup");
441 showMenuPopup->AddButton(tr(
"Scan For Changes"));
447 showMenuPopup->AddButton(tr(
"Show Information"));
448 if (romInfo->Favorite())
449 showMenuPopup->AddButton(tr(
"Remove Favorite"));
451 showMenuPopup->AddButton(tr(
"Make Favorite"));
452 showMenuPopup->AddButton(tr(
"Retrieve Details"));
453 showMenuPopup->AddButton(tr(
"Edit Details"));
460 delete showMenuPopup;
468 if (parent !=
nullptr)
470 QStringList childList;
471 QList<MythGenericTree*>::iterator it;
474 for (it = children->begin(); it != children->end(); ++it)
483 tr(
"Game Search"), childList,
true,
"");
485 if (searchDialog->Create())
517 QString resultid = dce->
GetId();
518 QString resulttext = dce->GetResultText();
520 if (resultid ==
"showMenuPopup")
522 if (resulttext == tr(
"Edit Details"))
526 if (resulttext == tr(
"Scan For Changes"))
530 else if (resulttext == tr(
"Show Information"))
534 else if (resulttext == tr(
"Make Favorite") ||
535 resulttext == tr(
"Remove Favorite"))
539 else if (resulttext == tr(
"Retrieve Details"))
544 else if (resultid ==
"chooseSystemPopup")
546 if (!resulttext.isEmpty() && resulttext != tr(
"Cancel"))
553 else if (resultid ==
"editMetadata")
559 auto *romInfo = dce->GetData().value<
RomInfo *>();
560 node->
SetData(QVariant::fromValue(romInfo));
561 node->
SetText(romInfo->Gamename());
563 romInfo->SaveToDatabase();
566 else if (resultid ==
"detailsPopup")
588 if (lul.count() == 1)
594 auto *resultsdialog =
599 Qt::QueuedConnection);
601 if (resultsdialog->Create())
629 LOG(VB_GENERAL, LOG_ERR,
630 QString(
"No results found for %1").arg(lookup->
GetTitle()));
656 QString layer = node->
GetText();
657 int childDepth = node->
getInt() + 1;
663 if (childLevel.isEmpty())
664 childLevel =
"gamename";
667 QString conj =
"where ";
669 if (!filter.isEmpty())
671 filter = conj + filter;
676 columns = childIsLeaf
677 ?
"romname,`system`,year,genre,gamename"
681 filter +=
" and romname like '" + layer +
"%'";
684 else if ((childLevel ==
"gamename") && (layer.length() == 1))
686 columns = childIsLeaf
687 ? childLevel +
",`system`,year,genre,gamename"
691 filter +=
" and gamename like '" + layer +
"%'";
694 else if (childLevel ==
"hash")
696 columns =
"left(gamename,1)";
701 columns = childIsLeaf
702 ? childLevel +
",`system`,year,genre,gamename"
710 if (!romInfo->System().isEmpty())
712 filter += conj +
"trim(system)=:SYSTEM";
715 if (!romInfo->Year().isEmpty())
717 filter += conj +
"year=:YEAR";
720 if (!romInfo->Genre().isEmpty())
722 filter += conj +
"trim(genre)=:GENRE";
725 if (!romInfo->Plot().isEmpty())
727 filter += conj +
"plot=:PLOT";
730 if (!romInfo->Publisher().isEmpty())
732 filter += conj +
"publisher=:PUBLISHER";
735 if (!romInfo->Gamename().isEmpty())
737 filter += conj +
"trim(gamename)=:GAMENAME";
742 filter += conj +
" display = 1 ";
748 sql =
"select distinct "
750 +
" from gamemetadata "
752 +
" order by romname"
755 else if (childLevel ==
"hash")
757 sql =
"select distinct "
759 +
" from gamemetadata "
761 +
" order by gamename,romname"
766 sql =
"select distinct "
768 +
" from gamemetadata "
780 unsigned this_level = node->
getInt();
781 while (node->
getInt() != 1)
785 return gi ? gi->
getLevel(this_level - 1) :
"<invalid>";
790 while (node->
getInt() != 1)
793 return gi ? gi->
getFilter() :
"<invalid>";
798 while (node->
getInt() != 1)
821 if (!romInfo->System().isEmpty())
822 query.bindValue(
":SYSTEM", romInfo->System());
823 if (!romInfo->Year().isEmpty())
824 query.bindValue(
":YEAR", romInfo->Year());
825 if (!romInfo->Genre().isEmpty())
826 query.bindValue(
":GENRE", romInfo->Genre());
827 if (!romInfo->Plot().isEmpty())
828 query.bindValue(
":PLOT", romInfo->Plot());
829 if (!romInfo->Publisher().isEmpty())
830 query.bindValue(
":PUBLISHER", romInfo->Publisher());
831 if (!romInfo->Gamename().isEmpty())
832 query.bindValue(
":GAMENAME", romInfo->Gamename());
836 if (query.exec() && query.size() > 0)
840 QString
current = query.value(0).toString().trimmed();
846 temp->setSystem(query.value(1).toString().trimmed());
847 temp->setYear(query.value(2).toString());
848 temp->setGenre(query.value(3).toString().trimmed());
849 temp->setGamename(query.value(4).toString().trimmed());
850 new_node->SetData(QVariant::fromValue(temp));
859 newRomInfo =
new RomInfo(*currentRomInfo);
865 new_node->SetData(QVariant::fromValue(newRomInfo));
882 QList<MythGenericTree*>::iterator it;
885 for (it = children->begin(); it != children->end(); ++it)
888 if (child != top_level)
926 lookup->SetData(QVariant::fromValue(node));
930 lookup->SetAutomatic(
true);
933 lookup->SetTitle(metadata->Gamename());
934 lookup->SetInetref(metadata->Inetref());
943 QString msg = tr(
"Fetching details for %1")
944 .arg(metadata->Gamename());
954 const QString& message = title;
957 "mythgamebusydialog");
993 metadata->setYear(QString::number(lookup->
GetYear()));
995 metadata->setSystem(lookup->
GetSystem());
997 QStringList coverart;
999 QStringList screenshot;
1003 for (
const auto & art : std::as_const(coverartlist))
1004 coverart.prepend(art.url);
1006 for (
const auto & art : std::as_const(fanartlist))
1007 fanart.prepend(art.url);
1009 for (
const auto & art : std::as_const(screenshotlist))
1010 screenshot.prepend(art.url);
1014 metadata->SaveToDatabase();
1019 QStringList fanart, QStringList screenshot)
1030 if (metadata->Boxart().isEmpty() && !coverart.empty())
1033 info.url = coverart.takeAt(0).trimmed();
1037 if (metadata->Fanart().isEmpty() && !fanart.empty())
1040 info.url = fanart.takeAt(0).trimmed();
1044 if (metadata->Screenshot().isEmpty() && !screenshot.empty())
1047 info.url = screenshot.takeAt(0).trimmed();
1052 lookup->SetTitle(metadata->Gamename());
1053 lookup->SetSystem(metadata->System());
1054 lookup->SetInetref(metadata->Inetref());
1056 lookup->SetDownloads(map);
1057 lookup->SetData(QVariant::fromValue(node));
1077 if (downloads.isEmpty())
1080 for (DownloadMap::iterator i = downloads.begin();
1081 i != downloads.end(); ++i)
1095 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)