diff --git a/README.md b/README.md index 6aa57508a5ba3a3ef864a3d00dd00cf12d34f6bc..e6b5e6f8a7661239f17d431b44214db6ff4218d0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Application développée dans le cadre de l’UV LO21 qui permet de répondre à - [Auteurs et licence](#auteurs) ## Pour commencer -Avoir une version de **Qt** d'au moins 5.12. Projet principalement testé sur Qt 5.15.2. +Avoir une version de **Qt** d'au moins 5.9. Projet principalement testé sur Qt 5.15.2. Le projet a été testé et fonctionne sur Qt 6, mais il est conseillé d'utiliser une version récente de Qt 5. Testé avec les compilateurs suivants : diff --git a/include/property.hpp b/include/property.hpp index 6b183f04433270a290aa2b12be2c14e5b287b7d2..b9d6b52fff441d46de57490602cef88a1e297b6c 100644 --- a/include/property.hpp +++ b/include/property.hpp @@ -18,6 +18,7 @@ Fichier définissant la classe Property représentant une propriété chargable, #include <memory> #include <limits> #include <exception> +#include <cassert> #include <QWidget> #include <QLayout> diff --git a/src/colorlabel.cpp b/src/colorlabel.cpp index d5dda1bc1a0ebeb199f8a40f7547b08da16f2fa8..d34cedf035021d3e19eefac8b3f60b7ba945c52c 100644 --- a/src/colorlabel.cpp +++ b/src/colorlabel.cpp @@ -6,6 +6,7 @@ #include "interface.hpp" #include <stdlib.h> #include <string> +#include <cassert> #include <QListWidget> #include <QColorDialog> #include <QMessageBox> diff --git a/src/gridview.cpp b/src/gridview.cpp index e3f64f92fef72c11e87272edc425aacf26bdea42..bac496daa7c5e14e49a096e0f6bf134048a40882 100644 --- a/src/gridview.cpp +++ b/src/gridview.cpp @@ -25,6 +25,7 @@ Cette classe représente le widget utilisé pour l'affichage et l'interaction av #include <vector> #include <cstdlib> +#include <cassert> #include <qmath.h> diff --git a/src/interface.cpp b/src/interface.cpp index 4fd3df90275357a9079c99be78f1fe691c652153..849d8c45076327f0d53cdc0281eed5faa662fc54 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -717,7 +717,6 @@ void MainWindow::play_bad_apple() { static QJsonArray bad_apple_frame_list; static QTimer bad_apple_timer; - static bool bad_apple_connected; #ifdef BAD_APPLE_AUDIO static QMediaPlayer bad_apple_player; #endif @@ -738,9 +737,8 @@ void MainWindow::play_bad_apple() bad_apple_timer.stop(); bad_apple_frame_list = frames["data"].toArray(); - if (!bad_apple_connected) { - bad_apple_timer.callOnTimeout([this] + connect(&bad_apple_timer, &QTimer::timeout, this, [this] { #ifdef BAD_APPLE_AUDIO unsigned frame_idx; @@ -775,7 +773,7 @@ void MainWindow::play_bad_apple() } ui->grid_view->copy_grid(grid); - }); + }, Qt::UniqueConnection); }; // On coupe la simulation si elle est en train de s'exécuter @@ -788,7 +786,7 @@ void MainWindow::play_bad_apple() bad_apple_player.setMedia(QUrl::fromLocalFile("extras/bad-apple.wav")); bad_apple_player.play(); #else - QMessageBox::information(this, "", "Music functionnality is only available with Qt 5"); + QMessageBox::information(this, "", "Music functionnality is only available with Qt Multimedia module (might be unavailable with Qt 6)"); #endif bad_apple_elapsed.start(); @@ -801,7 +799,6 @@ void MainWindow::play_snake() static QTimer snake_timer; static Coord snake_dir; static std::list<Coord> snake_body; - static bool snake_connected = false; statusBar()->showMessage("Controls : ZQSD", 60000); @@ -898,9 +895,9 @@ void MainWindow::play_snake() on_playPauseButton_clicked(); } - if (!snake_connected) + { - snake_timer.callOnTimeout([this] + connect(&snake_timer, &QTimer::timeout, this, [this] { if (m_arrow_key_state[0] && snake_dir != Coord{+1, 0}) snake_dir = {-1, 0}; @@ -911,8 +908,8 @@ void MainWindow::play_snake() else if (m_arrow_key_state[3] && snake_dir != Coord{0, +1}) snake_dir = {0, -1}; advance_snake(false); - }); - snake_connected = true; + }, Qt::UniqueConnection); + } snake_timer.start(100); } diff --git a/src/propertyvisitors.cpp b/src/propertyvisitors.cpp index 701bc33cde97bd17579335120476f07db84eb782..a4551563bbbe5c5e7a6213c393737bb20ce4eedd 100644 --- a/src/propertyvisitors.cpp +++ b/src/propertyvisitors.cpp @@ -120,7 +120,7 @@ QJsonValue PropertyLoaderVisitor::fetch_value(Property &prop) return val; } else - return current()[prop.identifier().c_str()]; + return current().toObject().value(prop.identifier().c_str()); } void PropertyLoaderVisitor::visit(StringProperty &prop) diff --git a/src/src.pro b/src/src.pro index 33979fbe651aa0407c4366a91b7733cf92cdfabd..02ad1d0d9b9234ebebe86e0746cbef532ce13ecb 100644 --- a/src/src.pro +++ b/src/src.pro @@ -8,6 +8,7 @@ qtHaveModule(multimedia): QT += multimedia CONFIG += c++14 TEMPLATE = app +TARGET = cellulut # Optimisations, flag pour garder les infos de debug QMAKE_CXXFLAGS += -O3 -g diff --git a/tests/alphabet_test.cpp b/tests/alphabet_test.cpp index 932843318e2b3dcd6aca3bb8d6b53e1c2ff357e2..a1fb47b307613cfde7938a51a389a0f6298749df 100644 --- a/tests/alphabet_test.cpp +++ b/tests/alphabet_test.cpp @@ -25,17 +25,17 @@ void CellulutTests::test_alphabet(){ unsigned char cb=sc.getBlue(); unsigned char cr=sc.getRed(); unsigned char cg=sc.getGreen(); - QCOMPARE(cb,126); - QCOMPARE(cg,5); - QCOMPARE(cr,1); + QCOMPARE(cb,(unsigned char)126); + QCOMPARE(cg,(unsigned char)5); + QCOMPARE(cr,(unsigned char)1); state test2=a.getState(2); stateColor sc2 =test2.getColor(); unsigned char cb2=sc2.getBlue(); unsigned char cr2=sc2.getRed(); unsigned char cg2=sc2.getGreen(); - QCOMPARE(cb2,74); - QCOMPARE(cg2,245); - QCOMPARE(cr2,144); + QCOMPARE(cb2,(unsigned char)74); + QCOMPARE(cg2,(unsigned char)245); + QCOMPARE(cr2,(unsigned char)144); } diff --git a/tests/arbitraryneighborhoodrule_test.cpp b/tests/arbitraryneighborhoodrule_test.cpp index 71c57550e21ca0ae5dcb40698aefe7906b5956f2..a743cd1923266e57f9262a299c97a33e52a44bdc 100644 --- a/tests/arbitraryneighborhoodrule_test.cpp +++ b/tests/arbitraryneighborhoodrule_test.cpp @@ -31,7 +31,7 @@ void CellulutTests::test_arbitrary_neighborhood_rule() prop->accept(visit); } - QCOMPARE(rule.getFormats().size(), 1ul); + QCOMPARE(rule.getFormats().size(), 1u); QCOMPARE(rule.getFormats()[0].positions.size(), coords.size()); auto list = rule.getFormats()[0].positions; diff --git a/tests/factory_tests.cpp b/tests/factory_tests.cpp index eb06d954af63ad1bb4bb8efabad9f4019118e743..35f2477e4d58093f9f96626744b2450b485edb08 100644 --- a/tests/factory_tests.cpp +++ b/tests/factory_tests.cpp @@ -37,11 +37,11 @@ void CellulutTests::test_factory() std::unique_ptr<Transition> life_trans = Factory<Transition>::make("life-like"); QVERIFY(life_trans != nullptr); - QCOMPARE(life_trans->say_hi(), "Life hi!\n"); + QCOMPARE(life_trans->say_hi(), std::string("Life hi!\n")); std::unique_ptr<Transition> gens_trans = Factory<Transition>::make("generations"); QVERIFY(gens_trans != nullptr); - QCOMPARE(gens_trans->say_hi(), "Generations hi!\n"); + QCOMPARE(gens_trans->say_hi(), std::string("Generations hi!\n")); QVERIFY(nullptr == Factory<Transition>::make("<invalid>")); diff --git a/tests/history_test.cpp b/tests/history_test.cpp index a814c31ed7b8d28f4bef46f14433d417e1b9152b..ac68fd1af32319d34c97b347533f6dcffeb4e001 100644 --- a/tests/history_test.cpp +++ b/tests/history_test.cpp @@ -27,12 +27,12 @@ void CellulutTests::test_history() // On pop la première grille puis la deuxième Grid popGrid = historyTest.popGrid(); - QCOMPARE(popGrid.get_state(pos2), 3ul); + QCOMPARE(popGrid.get_state(pos2), 3u); Grid topGrid = historyTest.topGrid(); QVERIFY(topGrid.get_state(pos1) == 2); popGrid = historyTest.popGrid(); - QCOMPARE(popGrid.get_state(pos1), 2ul); + QCOMPARE(popGrid.get_state(pos1), 2u); QVERIFY(historyTest.isEmpty() == true); // Push de trois grille (taille max de la pile de l'history = 2) @@ -41,11 +41,11 @@ void CellulutTests::test_history() historyTest.pushGrid(gridTest3); // La première grille est supprimée popGrid = historyTest.popGrid(); - QCOMPARE(popGrid.get_state(pos3), 4ul); + QCOMPARE(popGrid.get_state(pos3), 4u); topGrid = historyTest.topGrid(); QVERIFY(topGrid.get_state(pos2) == 3); popGrid = historyTest.popGrid(); - QCOMPARE(popGrid.get_state(pos2), 3ul); + QCOMPARE(popGrid.get_state(pos2), 3u); QVERIFY(historyTest.isEmpty() == true); } diff --git a/tests/property_test.cpp b/tests/property_test.cpp index 4761801a5e72bbcd967c0647c117db48278badf5..ac4aaca7ad44e5a5f78a7b39cb2af4801bc08375 100644 --- a/tests/property_test.cpp +++ b/tests/property_test.cpp @@ -28,7 +28,7 @@ void CellulutTests::test_property() test.coords.load_from_neighborhood(n); - QCOMPARE(test.coords.size(), 3ul); + QCOMPARE(test.coords.size(), 3u); for (unsigned i = 0; i < test.coords.size(); ++i) { CoordinateProperty& coord = static_cast<CoordinateProperty&>(test.coords.at(i)); diff --git a/tests/structure_test.cpp b/tests/structure_test.cpp index 6c95dc6ee4ce8c30faf4d60931284d3eef4fbad8..0f2565a10150aa08a6c9825450618020794f770a 100644 --- a/tests/structure_test.cpp +++ b/tests/structure_test.cpp @@ -24,8 +24,8 @@ void CellulutTests::test_structure() QVERIFY(std::is_permutation(normalized_coords.begin(), normalized_coords.end(), s1.begin())); QVERIFY(std::is_permutation(normalized_coords.begin(), normalized_coords.end(), s2.begin())); - QCOMPARE(s1.width(), 3ul); - QCOMPARE(s1.height(), 2ul); + QCOMPARE(s1.width(), 3u); + QCOMPARE(s1.height(), 2u); s1.load(empty.begin(), empty.end()); QVERIFY(s1.size() == 0); @@ -40,8 +40,8 @@ void CellulutTests::test_structure() QCOMPARE(s1.size(), coords.size()); // 2 cellules non nulles, on ignore les cellules à zéro qui sont toujours implicites QVERIFY(std::is_permutation(normalized_coords.begin(), normalized_coords.end(), s1.begin())); - QCOMPARE(s1.width(), 3ul); - QCOMPARE(s1.height(), 2ul); + QCOMPARE(s1.width(), 3u); + QCOMPARE(s1.height(), 2u); } } diff --git a/tests/structurereader_tests.cpp b/tests/structurereader_tests.cpp index 84b55c25b5936502222f6162a1a2a67652797082..ae95e67523c76a1a6ecbd433ba0dbf7e0bdf569a 100644 --- a/tests/structurereader_tests.cpp +++ b/tests/structurereader_tests.cpp @@ -39,7 +39,7 @@ void CellulutTests::test_rle_structurereader() try { Structure stru = rle.read_structure(); - QCOMPARE(stru.size(), 5ul); + QCOMPARE(stru.size(), 5u); QVERIFY(std::count(stru.begin(), stru.end(), std::make_pair<Coord, unsigned>(Coord{1, 0}, 1)) == 1); } catch (const std::exception& ex) @@ -55,7 +55,7 @@ void CellulutTests::test_rle_structurereader() try { Structure stru = rle.read_structure(); - QCOMPARE(stru.size(), 36ul); + QCOMPARE(stru.size(), 36u); } catch (const std::exception& ex) { @@ -70,7 +70,7 @@ void CellulutTests::test_rle_structurereader() try { Structure stru = rle.read_structure(); - QCOMPARE(stru.size(), 16ul); + QCOMPARE(stru.size(), 16u); std::map<int, int> state_count; for (auto pair : stru) @@ -96,7 +96,7 @@ void CellulutTests::test_json_structurereader() try { Structure stru = rle.read_structure(); - QCOMPARE(stru.size(), 2ul); + QCOMPARE(stru.size(), 2u); QVERIFY(std::count(stru.begin(), stru.end(), std::make_pair<Coord, unsigned>(Coord{0, 0}, 1)) == 1); QVERIFY(std::count(stru.begin(), stru.end(), std::make_pair<Coord, unsigned>(Coord{2, 3}, 3)) == 1); }