77 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'gameui'");
108 QString systemFilter;
114 for (
unsigned i = 0; i < handlercount; ++i)
118 systemFilter =
"`system` in ('" + system +
"'";
120 systemFilter +=
",'" + system +
"'";
122 if (systemFilter.isEmpty())
124 systemFilter =
"1=0";
125 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find any game handlers!"));
141 new_node->SetData(QVariant::fromValue(
142 new GameTreeInfo(levels, systemFilter +
" and favorite=1")));
149 int pos = levels.indexOf(
"gamename");
151 levels.insert(pos,
" hash ");
155 new_node->SetData(QVariant::fromValue(
160 new_node->SetData(QVariant::fromValue(
165 new_node->SetData(QVariant::fromValue(
170 new_node->SetData(QVariant::fromValue(
175 new_node->SetData(QVariant::fromValue(
191 for (
int i = 0; i < actions.size() && !handled; i++)
193 const QString&
action = actions[i];
198 else if (
action ==
"EDIT")
200 else if (
action ==
"INFO")
202 else if (
action ==
"TOGGLEFAV")
204 else if ((
action ==
"INCSEARCH") || (
action ==
"INCSEARCHNEXT"))
206 else if (
action ==
"DOWNLOADDATA")
237 if (romInfo->Romname().isEmpty())
240 if (!romInfo->Screenshot().isEmpty() || !romInfo->Fanart().isEmpty() ||
241 !romInfo->Boxart().isEmpty())
265 if (romInfo->RomCount() == 1)
272 QString msg = tr(
"Choose System for:\n%1").arg(node->
GetText());
274 GetStack(
"popup stack");
276 msg, popupStack,
"chooseSystemPopup");
278 if (chooseSystemPopup->Create())
280 chooseSystemPopup->SetReturnEvent(
this,
"chooseSystemPopup");
281 QString all_systems = romInfo->AllSystems();
282 QStringList players = all_systems.split(
',');
283 for (
const auto & player : std::as_const(players))
284 chooseSystemPopup->AddButton(player);
285 popupStack->
AddScreen(chooseSystemPopup);
289 delete chooseSystemPopup;
392 "mythgameeditmetadata", romInfo);
394 if (md_editor->Create())
396 screenStack->AddScreen(md_editor);
397 md_editor->SetReturnEvent(
this,
"editMetadata");
417 if (details_dialog->Create())
420 details_dialog->SetReturnEvent(
this,
"detailsPopup");
424 delete details_dialog;
434 GetStack(
"popup stack");
435 auto *showMenuPopup =
438 if (showMenuPopup->Create())
440 showMenuPopup->SetReturnEvent(
this,
"showMenuPopup");
442 showMenuPopup->AddButton(tr(
"Scan For Changes"));
448 showMenuPopup->AddButton(tr(
"Show Information"));
449 if (romInfo->Favorite())
450 showMenuPopup->AddButton(tr(
"Remove Favorite"));
452 showMenuPopup->AddButton(tr(
"Make Favorite"));
453 showMenuPopup->AddButton(tr(
"Retrieve Details"));
454 showMenuPopup->AddButton(tr(
"Edit Details"));
461 delete showMenuPopup;
469 if (parent !=
nullptr)
471 QStringList childList;
472 QList<MythGenericTree*>::iterator it;
475 for (it = children->begin(); it != children->end(); ++it)
484 tr(
"Game Search"), childList,
true,
"");
486 if (searchDialog->Create())
518 QString resultid = dce->
GetId();
519 QString resulttext = dce->GetResultText();
521 if (resultid ==
"showMenuPopup")
523 if (resulttext == tr(
"Edit Details"))
527 if (resulttext == tr(
"Scan For Changes"))
531 else if (resulttext == tr(
"Show Information"))
535 else if (resulttext == tr(
"Make Favorite") ||
536 resulttext == tr(
"Remove Favorite"))
540 else if (resulttext == tr(
"Retrieve Details"))
545 else if (resultid ==
"chooseSystemPopup")
547 if (!resulttext.isEmpty() && resulttext != tr(
"Cancel"))
554 else if (resultid ==
"editMetadata")
560 auto *romInfo = dce->GetData().value<
RomInfo *>();
561 node->
SetData(QVariant::fromValue(romInfo));
562 node->
SetText(romInfo->Gamename());
564 romInfo->SaveToDatabase();
567 else if (resultid ==
"detailsPopup")
589 if (lul.count() == 1)
595 auto *resultsdialog =
600 Qt::QueuedConnection);
602 if (resultsdialog->Create())
630 LOG(VB_GENERAL, LOG_ERR,
631 QString(
"No results found for %1").arg(lookup->
GetTitle()));
657 QString layer = node->
GetText();
658 int childDepth = node->
getInt() + 1;
664 if (childLevel.isEmpty())
665 childLevel =
"gamename";
668 QString conj =
"where ";
670 if (!filter.isEmpty())
672 filter = conj + filter;
677 columns = childIsLeaf
678 ?
"romname,`system`,year,genre,gamename"
682 filter +=
" and romname like '" + layer +
"%'";
685 else if ((childLevel ==
"gamename") && (layer.length() == 1))
687 columns = childIsLeaf
688 ? childLevel +
",`system`,year,genre,gamename"
692 filter +=
" and gamename like '" + layer +
"%'";
695 else if (childLevel ==
"hash")
697 columns =
"left(gamename,1)";
702 columns = childIsLeaf
703 ? childLevel +
",`system`,year,genre,gamename"
711 if (!romInfo->System().isEmpty())
713 filter += conj +
"trim(system)=:SYSTEM";
716 if (!romInfo->Year().isEmpty())
718 filter += conj +
"year=:YEAR";
721 if (!romInfo->Genre().isEmpty())
723 filter += conj +
"trim(genre)=:GENRE";
726 if (!romInfo->Plot().isEmpty())
728 filter += conj +
"plot=:PLOT";
731 if (!romInfo->Publisher().isEmpty())
733 filter += conj +
"publisher=:PUBLISHER";
736 if (!romInfo->Gamename().isEmpty())
738 filter += conj +
"trim(gamename)=:GAMENAME";
743 filter += conj +
" display = 1 ";
749 sql =
"select distinct "
751 +
" from gamemetadata "
753 +
" order by romname"
756 else if (childLevel ==
"hash")
758 sql =
"select distinct "
760 +
" from gamemetadata "
762 +
" order by gamename,romname"
767 sql =
"select distinct "
769 +
" from gamemetadata "
781 unsigned this_level = node->
getInt();
782 while (node->
getInt() != 1)
786 return gi ? gi->
getLevel(this_level - 1) :
"<invalid>";
791 while (node->
getInt() != 1)
794 return gi ? gi->
getFilter() :
"<invalid>";
799 while (node->
getInt() != 1)
822 if (!romInfo->System().isEmpty())
823 query.bindValue(
":SYSTEM", romInfo->System());
824 if (!romInfo->Year().isEmpty())
825 query.bindValue(
":YEAR", romInfo->Year());
826 if (!romInfo->Genre().isEmpty())
827 query.bindValue(
":GENRE", romInfo->Genre());
828 if (!romInfo->Plot().isEmpty())
829 query.bindValue(
":PLOT", romInfo->Plot());
830 if (!romInfo->Publisher().isEmpty())
831 query.bindValue(
":PUBLISHER", romInfo->Publisher());
832 if (!romInfo->Gamename().isEmpty())
833 query.bindValue(
":GAMENAME", romInfo->Gamename());
837 if (query.exec() && query.size() > 0)
841 QString
current = query.value(0).toString().trimmed();
847 temp->setSystem(query.value(1).toString().trimmed());
848 temp->setYear(query.value(2).toString());
849 temp->setGenre(query.value(3).toString().trimmed());
850 temp->setGamename(query.value(4).toString().trimmed());
851 new_node->SetData(QVariant::fromValue(temp));
860 newRomInfo =
new RomInfo(*currentRomInfo);
866 new_node->SetData(QVariant::fromValue(newRomInfo));
883 QList<MythGenericTree*>::iterator it;
886 for (it = children->begin(); it != children->end(); ++it)
889 if (child != top_level)
927 lookup->SetData(QVariant::fromValue(node));
931 lookup->SetAutomatic(
true);
934 lookup->SetTitle(metadata->Gamename());
935 lookup->SetInetref(metadata->Inetref());
944 QString msg = tr(
"Fetching details for %1")
945 .arg(metadata->Gamename());
955 const QString& message = title;
958 "mythgamebusydialog");
994 metadata->setYear(QString::number(lookup->
GetYear()));
996 metadata->setSystem(lookup->
GetSystem());
998 QStringList coverart;
1000 QStringList screenshot;
1004 for (
const auto & art : std::as_const(coverartlist))
1005 coverart.prepend(art.url);
1007 for (
const auto & art : std::as_const(fanartlist))
1008 fanart.prepend(art.url);
1010 for (
const auto & art : std::as_const(screenshotlist))
1011 screenshot.prepend(art.url);
1015 metadata->SaveToDatabase();
1020 QStringList fanart, QStringList screenshot)
1031 if (metadata->Boxart().isEmpty() && !coverart.empty())
1034 info.url = coverart.takeAt(0).trimmed();
1038 if (metadata->Fanart().isEmpty() && !fanart.empty())
1041 info.url = fanart.takeAt(0).trimmed();
1045 if (metadata->Screenshot().isEmpty() && !screenshot.empty())
1048 info.url = screenshot.takeAt(0).trimmed();
1053 lookup->SetTitle(metadata->Gamename());
1054 lookup->SetSystem(metadata->System());
1055 lookup->SetInetref(metadata->Inetref());
1057 lookup->SetDownloads(map);
1058 lookup->SetData(QVariant::fromValue(node));
1078 if (downloads.isEmpty())
1081 for (DownloadMap::iterator i = downloads.begin();
1082 i != downloads.end(); ++i)
1096 metadata->SaveToDatabase();
1118#include "moc_gameui.cpp"
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)