From b7413384aafca679584df1e5e18dd7e6282ff4f3 Mon Sep 17 00:00:00 2001 From: John Fultz Date: Wed, 17 Jun 2020 23:52:03 -0500 Subject: Xcode compiler warnings. * Replace std::random_shuffle() with std::shuffle(). * Populate switch statements which were checking the Move enums, but not Move::PlaceError. * endl -> Qt::endl for QTextStream usage. * QString::SkipEmptyParts -> Qt::SkipEmptyParts * QLabel::pixmap() now takes Qt::ReturnByValue * Use QElapsedTimer where appropriate. --- quacker/boarddisplay.cpp | 4 ++++ quacker/graphicalreporter.cpp | 18 +++++++++--------- quacker/graphicalreporter.h | 7 +++++++ quacker/letterbox.cpp | 4 ++++ quacker/letterbox.h | 5 +++-- quacker/quacker.cpp | 2 +- quacker/rackdisplay.cpp | 4 ++++ 7 files changed, 32 insertions(+), 12 deletions(-) (limited to 'quacker') diff --git a/quacker/boarddisplay.cpp b/quacker/boarddisplay.cpp index e64cb36..677179e 100644 --- a/quacker/boarddisplay.cpp +++ b/quacker/boarddisplay.cpp @@ -128,7 +128,11 @@ void BoardWithQuickEntry::provideHelp() void BoardWithQuickEntry::processCommand(const QString &command) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + QStringList items(command.split(" ", Qt::SkipEmptyParts)); +#else QStringList items(command.split(" ", QString::SkipEmptyParts)); +#endif Quackle::Move move(Quackle::Move::createNonmove()); if (items.size() <= 0) diff --git a/quacker/graphicalreporter.cpp b/quacker/graphicalreporter.cpp index 8111f7b..86b539d 100644 --- a/quacker/graphicalreporter.cpp +++ b/quacker/graphicalreporter.cpp @@ -94,27 +94,27 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu if (image.save(filename, "PNG")) { - m_indexStream << QString("%2").arg(filebasename).arg(title) << endl; + m_indexStream << QString("%2").arg(filebasename).arg(title) << m_endl; } else { QMessageBox::critical(0, GraphicalBoard::tr("Error Writing File - Quacker"), GraphicalBoard::tr("Could not write image %1.").arg(filename)); } - m_indexStream << "

" << endl; + m_indexStream << "

" << m_endl; } else { m_indexStream << title; const int boardTileSize = position.gameOver()? 45 : 25; - m_indexStream << QuackleIO::Util::sanitizeUserVisibleLetterString(QuackleIO::Util::uvStringToQString(position.board().htmlBoard(boardTileSize))) << endl; + m_indexStream << QuackleIO::Util::sanitizeUserVisibleLetterString(QuackleIO::Util::uvStringToQString(position.board().htmlBoard(boardTileSize))) << m_endl; } } const Quackle::PlayerList players(position.endgameAdjustedScores()); - m_indexStream << "" << endl; + m_indexStream << "
" << m_endl; for (Quackle::PlayerList::const_iterator it = players.begin(); it != players.end(); ++it) { m_indexStream << ""; @@ -131,9 +131,9 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu << "" << "" << "" - << endl; + << m_endl; } - m_indexStream << "
" << QuackleIO::Util::sanitizeUserVisibleLetterString(QuackleIO::Util::uvStringToQString((*it).rack().toString())) << "" << (*it).score() << "
" << endl; + m_indexStream << "" << m_endl; if (computerPlayer && !position.gameOver()) { @@ -153,7 +153,7 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu moves.push_back(position.committedMove()); } - m_indexStream << "
    " << endl; + m_indexStream << "
      " << m_endl; for (Quackle::MoveList::const_iterator it = moves.begin(); it != moves.end(); ++it) { QString item; @@ -203,9 +203,9 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu item += QString("  ←"); if (!item.isEmpty()) - m_indexStream << "
    1. " << item << "
    2. " << endl; + m_indexStream << "
    3. " << item << "
    4. " << m_endl; } - m_indexStream << "
    " << endl; + m_indexStream << "
" << m_endl; } m_indexStream << "\n\n"; diff --git a/quacker/graphicalreporter.h b/quacker/graphicalreporter.h index fd2b52d..997fdb4 100644 --- a/quacker/graphicalreporter.h +++ b/quacker/graphicalreporter.h @@ -60,4 +60,11 @@ protected: bool m_generateImages; }; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !defined(m_endl) +# define m_endl Qt::endl +#elif !defined(m_endl) +# define m_endl endl +#endif + + #endif diff --git a/quacker/letterbox.cpp b/quacker/letterbox.cpp index 8edcaa5..aeed7af 100644 --- a/quacker/letterbox.cpp +++ b/quacker/letterbox.cpp @@ -358,7 +358,11 @@ ClueResult Letterbox::parseComment(const QString &comment) if (comment.isEmpty()) return ClueResult(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + QStringList items = comment.split(" ", Qt::SkipEmptyParts); +#else QStringList items = comment.split(" ", QString::SkipEmptyParts); +#endif ClueResult ret; diff --git a/quacker/letterbox.h b/quacker/letterbox.h index 8aa171d..c340f1d 100644 --- a/quacker/letterbox.h +++ b/quacker/letterbox.h @@ -19,6 +19,7 @@ #ifndef QUACKER_LETTERBOX_H #define QUACKER_LETTERBOX_H +#include #include #include #include @@ -204,8 +205,8 @@ private: ListerDialog *m_listerDialog; QTimer *m_timer; - QTime m_time; - QTime m_pauseTime; + QElapsedTimer m_time; + QElapsedTimer m_pauseTime; int m_pauseMs; int m_keystrokes; diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp index 20b2f88..4e91498 100644 --- a/quacker/quacker.cpp +++ b/quacker/quacker.cpp @@ -656,7 +656,7 @@ void TopLevel::initializeGame(const Quackle::PlayerList &players) UVString prevFirst = m_firstPlayerName; while (m_firstPlayerName == prevFirst || m_firstPlayerName.empty()) { - random_shuffle(newPlayers.begin(), newPlayers.end()); + QUACKLE_DATAMANAGER->shuffle(newPlayers); m_firstPlayerName = newPlayers.front().name(); if (all_of(newPlayers.begin(), newPlayers.end(), diff --git a/quacker/rackdisplay.cpp b/quacker/rackdisplay.cpp index 59b91e7..b0f10f5 100644 --- a/quacker/rackdisplay.cpp +++ b/quacker/rackdisplay.cpp @@ -242,7 +242,11 @@ GraphicalRack::mousePressEvent (QMouseEvent* event) if (!child) return; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + QPixmap pixmap = child->pixmap(Qt::ReturnByValue); +#else QPixmap pixmap = *(child->pixmap()); +#endif QByteArray itemData; QDataStream dataStream (&itemData, QIODevice::WriteOnly); -- cgit v1.2.3