diff --git a/build/Desktop_Qt_6_9_0_MinGW_64_bit-Debug/.qmake.stash b/build/Desktop_Qt_6_9_0_MinGW_64_bit-Debug/.qmake.stash new file mode 100644 index 0000000..8e49e8a --- /dev/null +++ b/build/Desktop_Qt_6_9_0_MinGW_64_bit-Debug/.qmake.stash @@ -0,0 +1,21 @@ +QMAKE_CXX.QT_COMPILER_STDCXX = 201703L +QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 13 +QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 1 +QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_GCC_MAJOR_VERSION \ + QMAKE_GCC_MINOR_VERSION \ + QMAKE_GCC_PATCH_VERSION +QMAKE_CXX.INCDIRS = \ + C:/Qt/Tools/mingw1310_64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++ \ + C:/Qt/Tools/mingw1310_64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/x86_64-w64-mingw32 \ + C:/Qt/Tools/mingw1310_64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/backward \ + C:/Qt/Tools/mingw1310_64/lib/gcc/x86_64-w64-mingw32/13.1.0/include \ + C:/Qt/Tools/mingw1310_64/lib/gcc/x86_64-w64-mingw32/13.1.0/include-fixed \ + C:/Qt/Tools/mingw1310_64/x86_64-w64-mingw32/include +QMAKE_CXX.LIBDIRS = \ + C:/Qt/Tools/mingw1310_64/lib/gcc/x86_64-w64-mingw32/13.1.0 \ + C:/Qt/Tools/mingw1310_64/lib/gcc \ + C:/Qt/Tools/mingw1310_64/x86_64-w64-mingw32/lib \ + C:/Qt/Tools/mingw1310_64/lib diff --git a/data.qrc b/data.qrc new file mode 100644 index 0000000..2f0a67e --- /dev/null +++ b/data.qrc @@ -0,0 +1,5 @@ + + + ex.txt + + diff --git a/ex.txt b/ex.txt new file mode 100644 index 0000000..563752a --- /dev/null +++ b/ex.txt @@ -0,0 +1,7 @@ +{ + "id": 1, + "texte": "tkt", + "latitude": "N 45 37.199", + "longitude": "W 1 2.009", + "valeur": -1 +} diff --git a/main.cpp b/main.cpp index 2c8cdf2..0c0a6eb 100644 --- a/main.cpp +++ b/main.cpp @@ -4,13 +4,14 @@ #include #include +#include +using namespace std; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; - w.show(); - + //w.show(); return a.exec(); } diff --git a/path.cpp b/path.cpp index 4f4fd97..64a2a09 100644 --- a/path.cpp +++ b/path.cpp @@ -41,4 +41,11 @@ Path::Path(QFile *file){ } -void Path::addStep(int indice){step.insert(indice, Step());} +void Path::addStep(int indice){ + if(indice==-1){ + step.append(Step()); + }else{ + step.insert(indice, Step()); + } + +} diff --git a/path.h b/path.h index b990bbb..f95f24b 100644 --- a/path.h +++ b/path.h @@ -20,7 +20,7 @@ private: public: Path(); Path(QFile *file); - void addStep(int indice=step.size()); + void addStep(int indice=-1); }; #endif // PATH_H diff --git a/sae201.pro b/sae201.pro index 2019663..8cb9d3f 100644 --- a/sae201.pro +++ b/sae201.pro @@ -26,3 +26,7 @@ FORMS += \ qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + data.qrc + diff --git a/step.cpp b/step.cpp index 17f2edc..861f414 100644 --- a/step.cpp +++ b/step.cpp @@ -1,26 +1,73 @@ #include "step.h" +#include +#include +#include +#include +#include +#include +#include +QString Step::getTitle() const +{ + return title; +} + +float Step::getLatitude() const +{ + return latitude; +} + +float Step::getLongitude() const +{ + return longitude; +} + +int Step::getResponse() const +{ + return response; +} + Step::Step() { latitude = 0.0; longitude = 0.0; response = 0; } -Step::Step(QTextStream &in) + +Step::Step( QJsonObject &in) { - int stepNumber; - in >> stepNumber; - in.readLine(); - title = in.readLine(); - QChar latDir, lonDir; - int latDeg, lonDeg; - float latMin, lonMin; - in >> latDir >> latDeg >> latMin >> lonDir >> lonDeg >> lonMin; + title = in["title"].toString(); + response = in["reponse"].toInt(); + QString gps = in["GPS"].toString(); + QStringList parts = gps.split(" ", Qt::SkipEmptyParts); + + QChar latDir = parts[0][0]; // c'est le premier QChar du QString t'as capté + int latDeg = parts[1].toInt(); + float latMin = parts[2].toFloat(); setLatitude(latDeg, latMin, latDir); + + QChar lonDir = parts[3][0]; + int lonDeg = parts[4].toInt(); + float lonMin = parts[5].toFloat(); setLongitude(lonDeg, lonMin, lonDir); - in >> response; - in.readLine(); + + QJsonArray personnagetab = in["dialogue"].toArray(); + for (const QJsonValue &val : personnagetab) { + if (val.isObject()) { + QJsonObject obj = val.toObject(); + QString personnages = obj["personnage"].toString(); + personnage.append(personnages); + QString textes = obj["texte"].toString(); + texte.append(textes); + } + } + + } + + + + void Step::setLatitude(int degree, float minute, QChar NS) { latitude = degree + minute / 60.0; diff --git a/step.h b/step.h index eb46bbc..8d93c46 100644 --- a/step.h +++ b/step.h @@ -2,6 +2,10 @@ #define STEP_H #include #include +#include +#include +#include +using namespace std; class Step { @@ -9,14 +13,19 @@ private: QString title; float latitude; float longitude; - QString text; int response; + QList personnage; + QList texte; public: Step(); - Step(QTextStream &in); + Step(QJsonObject &in); void setLatitude(int degree,float minute,QChar NS); void setLongitude(int degree,float minute,QChar EW); + QString getTitle() const; + float getLatitude() const; + float getLongitude() const; + int getResponse() const; }; #endif // STEP_H