Add more QLatin1Char

This commit is contained in:
Laurent Montel 2019-04-19 07:59:51 +02:00
parent c9a2a39e3b
commit c356a4acf9
3 changed files with 20 additions and 20 deletions

View file

@ -69,9 +69,9 @@ Game::~Game()
bool Game::start(const QString &command)
{
stop(); // Close old session if there's one
m_process.start(command.toLatin1()); // Start new process with provided command
m_process.start(command); // Start new process with provided command
if (!m_process.waitForStarted()) { // Blocking wait for process start
m_response = "Unable to execute command: " + command;
m_response = QStringLiteral("Unable to execute command: ") + command;
//qDebug() << m_response;
return false;
}
@ -520,7 +520,7 @@ int Game::moveCount()
m_process.write("move_history\n"); // Query fixed handicap and store it
if (waitResponse()) {
return m_response.count('\n') + 1;
return m_response.count(QLatin1Char('\n')) + 1;
}
return 0;
}
@ -536,7 +536,7 @@ QList<Stone> Game::stones(const Player &player)
if (!player.isWhite()) {
m_process.write("list_stones black\n");
if (waitResponse() && !m_response.isEmpty()) {
foreach (const QString &pos, m_response.split(' ')) {
foreach (const QString &pos, m_response.split(QLatin1Char(' '))) {
list.append(Stone(pos));
}
}
@ -544,7 +544,7 @@ QList<Stone> Game::stones(const Player &player)
if (!player.isBlack()) {
m_process.write("list_stones white\n");
if (waitResponse() && !m_response.isEmpty()) {
foreach (const QString &pos, m_response.split(' ')) {
foreach (const QString &pos, m_response.split(QLatin1Char(' '))) {
list.append(Stone(pos));
}
}
@ -580,7 +580,7 @@ QList<Stone> Game::liberties(const Stone &stone)
m_process.write("findlib " + stone.toLatin1() + '\n');
if (waitResponse() && !m_response.isEmpty()) {
foreach (const QString &entry, m_response.split(' ')) {
foreach (const QString &entry, m_response.split(QLatin1Char(' '))) {
list.append(Stone(entry));
}
}
@ -600,7 +600,7 @@ QList<Stone> Game::bestMoves(const Player &player)
m_process.write("top_moves_black\n");
}
if (waitResponse(true) && !m_response.isEmpty()) {
const QStringList parts = m_response.split(' ');
const QStringList parts = m_response.split(QLatin1Char(' '));
if (parts.size() % 2 == 0) {
for (int i = 0; i < parts.size(); i += 2) {
list.append(Stone(parts[i], QString(parts[i + 1]).toFloat()));
@ -623,7 +623,7 @@ QList<Stone> Game::legalMoves(const Player &player)
m_process.write("all_legal black\n");
}
if (waitResponse() && !m_response.isEmpty()) {
foreach (const QString &entry, m_response.split(' ')) {
foreach (const QString &entry, m_response.split(QLatin1Char(' '))) {
list.append(Stone(entry));
}
}
@ -684,7 +684,7 @@ QList<Stone> Game::finalStates(FinalState state)
msg.append('\n');
m_process.write(msg);
if (waitResponse() && !m_response.isEmpty()) {
foreach (const QString &entry, m_response.split(' ')) {
foreach (const QString &entry, m_response.split(QLatin1Char(' '))) {
list.append(Stone(entry));
}
}
@ -761,7 +761,7 @@ bool Game::waitResponse(bool nonBlocking)
QChar tmp = m_response[0]; // First message character indicates success or error
m_response.remove(0, 2); // Remove the first two chars (e.g. "? " or "= ")
m_response = m_response.trimmed(); // Remove further whitespaces, newlines, ...
return tmp != '?'; // '?' Means the game didn't understand the query
return tmp != QLatin1Char('?'); // '?' Means the game didn't understand the query
}
void Game::gameSetup()

View file

@ -23,20 +23,20 @@
namespace Kigo {
Score::Score(const QString &score)
: m_color('?'), m_score(0), m_lowerBound(0), m_upperBound(0)
: m_color(QLatin1Char('?')), m_score(0), m_lowerBound(0), m_upperBound(0)
{
if (score.size() >= 2) {
if (score[0] == 'W') {
m_color = 'W';
} else if (score[0] == 'B') {
m_color = 'B';
if (score[0] == QLatin1Char('W')) {
m_color = QLatin1Char('W');
} else if (score[0] == QLatin1Char('B')) {
m_color = QLatin1Char('B');
}
int i = score.indexOf(' ');
int i = score.indexOf(QLatin1Char(' '));
m_score = score.midRef(2, i - 1).toFloat();
QString upperBound = score.section(' ', 3, 3);
QString upperBound = score.section(QLatin1Char(' '), 3, 3);
upperBound.chop(1);
m_upperBound = upperBound.toFloat();
QString lowerBound = score.section(' ', 5, 5);
QString lowerBound = score.section(QLatin1Char(' '), 5, 5);
lowerBound.chop(1);
m_lowerBound = lowerBound.toFloat();
}
@ -59,7 +59,7 @@ Score &Score::operator=(const Score &other)
bool Score::isValid() const
{
return m_score >= 0 && (m_color == 'W' || m_color == 'B');
return m_score >= 0 && (m_color == QLatin1Char('W') || m_color == QLatin1Char('B'));
}
QString Score::toString() const

View file

@ -273,7 +273,7 @@ void MainWindow::finishGame()
//qDebug() << "Fetching final score from engine ...";
Score score = m_game->estimatedScore();
QString name;
if (score.color() == 'W') {
if (score.color() == QLatin1Char('W')) {
name = m_game->whitePlayer().name() + " (White)";
} else {
name = m_game->blackPlayer().name() + " (Black)";