crew number parse added

This commit is contained in:
Rafael 2016-03-21 21:46:36 +01:00
parent a3c66786eb
commit 5e1d5d14bf
4 changed files with 42 additions and 11 deletions

View File

@ -48,6 +48,7 @@ void PictureDialog::setJsonString(SnapmaticPicture *picture)
QString locX = QString::number(picture->getLocationX()); QString locX = QString::number(picture->getLocationX());
QString locY = QString::number(picture->getLocationY()); QString locY = QString::number(picture->getLocationY());
QString locZ = QString::number(picture->getLocationZ()); QString locZ = QString::number(picture->getLocationZ());
QString crewID = QString::number(picture->getCrewNumber());
QStringList plyrsList = picture->getPlayers(); QStringList plyrsList = picture->getPlayers();
QString plyrsStr; QString plyrsStr;
@ -58,5 +59,5 @@ void PictureDialog::setJsonString(SnapmaticPicture *picture)
} }
if (plyrsStr.length() >= 1) { plyrsStr.remove(0,2); } if (plyrsStr.length() >= 1) { plyrsStr.remove(0,2); }
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr)); ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID));
} }

View File

@ -37,7 +37,8 @@
<widget class="QLabel" name="labJSON"> <widget class="QLabel" name="labJSON">
<property name="text"> <property name="text">
<string>Location: X: %1 Y: %2 Z: %3 <string>Location: X: %1 Y: %2 Z: %3
Players: %4</string> Players: %4
Crew ID: %5</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -25,22 +25,32 @@
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
int snapmaticHeaderLength = 278;
int snapmaticUsefulLength = 256;
int jpegPreHeaderLength = 14;
int jpegPicStreamLength = 524288;
int jsonStreamLength = 3076;
SnapmaticPicture::SnapmaticPicture(QObject *parent, QString fileName) : QObject(parent) SnapmaticPicture::SnapmaticPicture(QObject *parent, QString fileName) : QObject(parent)
{ {
// Init // PARSE INT INIT - DO NOT CHANGE THIS VALUES
snapmaticHeaderLength = 278;
snapmaticUsefulLength = 256;
jpegHeaderLineDifStr = 2;
jpegPreHeaderLength = 14;
jpegPicStreamLength = 524288;
jsonStreamLength = 3076;
// INIT PIC
cachePicture = QPixmap(0,0); cachePicture = QPixmap(0,0);
picFileName = ""; picFileName = "";
pictureStr = ""; pictureStr = "";
lastStep = ""; lastStep = "";
jsonStr = "";
// Set pic fileName // INIT JSON
jsonStr = "";
jsonLocX = 0;
jsonLocY = 0;
jsonLocZ = 0;
jsonCrewID = 0;
jsonPlyrsList = QStringList();
// SET PIC FILENAME
if (fileName != "") if (fileName != "")
{ {
picFileName = fileName; picFileName = fileName;
@ -77,7 +87,7 @@ bool SnapmaticPicture::readingPicture()
QByteArray jpegHeaderLine = picFile->read(jpegPreHeaderLength); QByteArray jpegHeaderLine = picFile->read(jpegPreHeaderLength);
// Checking for JPEG // Checking for JPEG
jpegHeaderLine.remove(0,2); jpegHeaderLine.remove(0, jpegHeaderLineDifStr);
if (jpegHeaderLine.left(4) != "JPEG") if (jpegHeaderLine.left(4) != "JPEG")
{ {
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",2,NOJPEG"; lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",2,NOJPEG";
@ -183,6 +193,10 @@ void SnapmaticPicture::parseJsonContent()
if (locMap.contains("y")) { jsonLocY = locMap["y"].toDouble(); } if (locMap.contains("y")) { jsonLocY = locMap["y"].toDouble(); }
if (locMap.contains("z")) { jsonLocZ = locMap["z"].toDouble(); } if (locMap.contains("z")) { jsonLocZ = locMap["z"].toDouble(); }
} }
if (jsonMap.contains("crewid"))
{
jsonCrewID = jsonMap["crewid"].toInt();
}
if (jsonMap.contains("plyrs")) if (jsonMap.contains("plyrs"))
{ {
jsonPlyrsList = jsonMap["plyrs"].toStringList(); jsonPlyrsList = jsonMap["plyrs"].toStringList();
@ -194,6 +208,11 @@ QString SnapmaticPicture::getJsonStr()
return jsonStr; return jsonStr;
} }
int SnapmaticPicture::getCrewNumber()
{
return jsonCrewID;
}
double SnapmaticPicture::getLocationX() double SnapmaticPicture::getLocationX()
{ {
return jsonLocX; return jsonLocX;

View File

@ -39,6 +39,7 @@ public:
QString getPictureStr(); QString getPictureStr();
// JSON // JSON
int getCrewNumber();
QString getJsonStr(); QString getJsonStr();
double getLocationX(); double getLocationX();
double getLocationY(); double getLocationY();
@ -55,8 +56,17 @@ private:
QString pictureStr; QString pictureStr;
QString lastStep; QString lastStep;
// PARSE INT
int snapmaticHeaderLength;
int snapmaticUsefulLength;
int jpegHeaderLineDifStr;
int jpegPreHeaderLength;
int jpegPicStreamLength;
int jsonStreamLength;
// JSON // JSON
void parseJsonContent(); void parseJsonContent();
int jsonCrewID;
QString jsonStr; QString jsonStr;
double jsonLocX; double jsonLocX;
double jsonLocY; double jsonLocY;