Commit 2967f512 authored by Laurent Montel's avatar Laurent Montel 😁

Make it compile without foreach

parent 72b1b159
......@@ -44,6 +44,10 @@ include(ECMQtDeclareLoggingCategory)
find_package(KF5KMahjongglib REQUIRED)
find_package(KF5KDEGames 4.9.0 REQUIRED)
if (${KF5Config_VERSION} STRGREATER "5.56.0")
add_definitions(-DQT_NO_FOREACH)
MESSAGE(STATUS "compile without foreach")
endif()
add_definitions(
-DQT_STRICT_ITERATORS
......
......@@ -691,7 +691,7 @@ void Board::paintEvent(QPaintEvent * e)
if (m_paintPossibleMoves) {
p.setPen(QPen(QColor("blue"), lineWidth()));
// paint all possible moves
foreach (auto const move, m_possibleMoves) {
for (auto const &move : qAsConst(m_possibleMoves)) {
auto pt1 = move.path().cbegin();
auto pt2 = pt1 + 1;
while (pt2 != move.path().cend()) {
......@@ -894,7 +894,7 @@ void Board::marked(TilePos const & tilePos)
{
if (field(tilePos) == EMPTY) { // click on empty space on the board
if (m_possibleMoves.size() > 1) { // if the click is on any of the current possible moves, make that move
foreach (auto move, m_possibleMoves) {
for (auto move : qAsConst(m_possibleMoves)) {
if (move.isInPath(tilePos)) {
performMove(move);
emit selectATile();
......@@ -932,7 +932,7 @@ void Board::marked(TilePos const & tilePos)
}
if (m_possibleMoves.size() > 1) { // if the click is on any of the current possible moves, make that move
foreach (auto move, m_possibleMoves) {
for (auto move : qAsConst(m_possibleMoves)) {
if (move.isInPath(tilePos)) {
performMove(move);
emit selectATile();
......@@ -955,7 +955,7 @@ void Board::marked(TilePos const & tilePos)
if (findPath(TilePos(m_markX, m_markY), tilePos, m_possibleMoves) > 0) {
if (m_possibleMoves.size() > 1) {
auto withSlide = 0;
foreach (auto const move, m_possibleMoves) {
for (auto const &move : qAsConst(m_possibleMoves)) {
move.Debug();
if (move.hasSlide()) {
++withSlide;
......
......@@ -70,13 +70,13 @@ void PossibleMove::Debug() const
{
qCDebug(KSHISEN_General) << "PossibleMove";
foreach (auto const iter, m_path) {
for (auto const &iter : qAsConst(m_path)) {
qCDebug(KSHISEN_General) << " Path:" << iter.x() << "," << iter.y();
}
if (m_hasSlide) {
qCDebug(KSHISEN_General) << " hasSlide";
foreach (auto const iter, m_slide) {
for (auto const &iter : qAsConst(m_slide)) {
qCDebug(KSHISEN_General) << " Slide:" << iter.x() << "," << iter.y();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment