Skip to content

Commit

Permalink
MythGame: Replace "Clear Game Data" popup with MythUI equivalent.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McNamara authored and Beirdo committed Jan 2, 2011
1 parent bd4d1ee commit 44c2575
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
58 changes: 33 additions & 25 deletions mythplugins/mythgame/mythgame/gamehandler.cpp
Expand Up @@ -586,32 +586,20 @@ int GameHandler::buildFileCount(QString directory, GameHandler *handler)

void GameHandler::clearAllGameData(void)
{
QStringList buttonText;
buttonText += QObject::tr("No");
buttonText += QObject::tr("Yes");

DialogCode result = MythPopupBox::ShowButtonPopup(
GetMythMainWindow(),
QObject::tr("Are you sure?"),
QString(QObject::tr("This will clear all Game Meta Data\n"
"from the database. Are you sure you\n"
"want to do this?" )),
buttonText, kDialogCodeButton0);

switch (result)
MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
MythDialogBox *clearPopup = new MythDialogBox(tr("This will clear all game metadata "
"from the database. Are you sure you "
"want to do this?"), popupStack, "clearAllPopup");

if (clearPopup->Create())
{
case kDialogCodeRejected:
case kDialogCodeButton0:
default:
// Do Nothing
break;
case kDialogCodeButton1:
MSqlQuery query(MSqlQuery::InitCon());
if (!query.exec("DELETE FROM gamemetadata;"))
MythDB::DBError("GameHandler::clearAllGameData - "
"delete gamemetadata", query);
break;
};
clearPopup->SetReturnEvent(this, "clearAllPopup");
clearPopup->AddButton(tr("No"));
clearPopup->AddButton(tr("Yes"));
popupStack->AddScreen(clearPopup);
}
else
delete clearPopup;
}

void GameHandler::buildFileList(QString directory, GameHandler *handler,
Expand Down Expand Up @@ -950,5 +938,25 @@ void GameHandler::customEvent(QEvent *event)
break;
};
}
else if (resultid == "clearAllPopup")
{
int buttonNum = dce->GetResult();
switch (buttonNum)
{
case 1:
clearAllMetadata();
break;
default:
break;
}
}
}
}

void GameHandler::clearAllMetadata(void)
{
MSqlQuery query(MSqlQuery::InitCon());
if (!query.exec("DELETE FROM gamemetadata;"))
MythDB::DBError("GameHandler::clearAllGameData - "
"delete gamemetadata", query);
}
4 changes: 3 additions & 1 deletion mythplugins/mythgame/mythgame/gamehandler.h
Expand Up @@ -81,7 +81,7 @@ class GameHandler : public QObject
void UpdateGameDB(GameHandler *handler);
void VerifyGameDB(GameHandler *handler);

static void clearAllGameData(void);
void clearAllGameData(void);

static int buildFileCount(QString directory, GameHandler *handler);
void buildFileList(QString directory, GameHandler *handler,
Expand All @@ -108,6 +108,8 @@ class GameHandler : public QObject
uint GamePlayerID() const { return gameplayerid; }
QString GameType() const { return gametype; }

void clearAllMetadata(void);

protected:
static GameHandler* GetHandler(RomInfo *rominfo);
static GameHandler* GetHandlerByName(QString systemname);
Expand Down
3 changes: 2 additions & 1 deletion mythplugins/mythgame/mythgame/main.cpp
Expand Up @@ -51,7 +51,8 @@ static void GameCallback(void *data, QString &selection)
}
if (sel == "clear_game_data")
{
GameHandler::clearAllGameData();
GameHandler *handler = new GameHandler();
handler->clearAllGameData();
}

}
Expand Down

0 comments on commit 44c2575

Please sign in to comment.