crew number parse added
This commit is contained in:
		
							parent
							
								
									a3c66786eb
								
							
						
					
					
						commit
						5e1d5d14bf
					
				
					 4 changed files with 42 additions and 11 deletions
				
			
		|  | @ -48,6 +48,7 @@ void PictureDialog::setJsonString(SnapmaticPicture *picture) | |||
|     QString locX = QString::number(picture->getLocationX()); | ||||
|     QString locY = QString::number(picture->getLocationY()); | ||||
|     QString locZ = QString::number(picture->getLocationZ()); | ||||
|     QString crewID = QString::number(picture->getCrewNumber()); | ||||
|     QStringList plyrsList = picture->getPlayers(); | ||||
| 
 | ||||
|     QString plyrsStr; | ||||
|  | @ -58,5 +59,5 @@ void PictureDialog::setJsonString(SnapmaticPicture *picture) | |||
|     } | ||||
|     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)); | ||||
| } | ||||
|  |  | |||
|  | @ -37,7 +37,8 @@ | |||
|     <widget class="QLabel" name="labJSON"> | ||||
|      <property name="text"> | ||||
|       <string>Location: X: %1 Y: %2 Z: %3 | ||||
| Players: %4</string> | ||||
| Players: %4 | ||||
| Crew ID: %5</string> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|  |  | |||
|  | @ -25,22 +25,32 @@ | |||
| #include <QString> | ||||
| #include <QDebug> | ||||
| #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) | ||||
| { | ||||
|     // 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); | ||||
|     picFileName = ""; | ||||
|     pictureStr = ""; | ||||
|     lastStep = ""; | ||||
|     jsonStr = ""; | ||||
| 
 | ||||
|     // Set pic fileName
 | ||||
|     // INIT JSON
 | ||||
|     jsonStr = ""; | ||||
|     jsonLocX = 0; | ||||
|     jsonLocY = 0; | ||||
|     jsonLocZ = 0; | ||||
|     jsonCrewID = 0; | ||||
|     jsonPlyrsList = QStringList(); | ||||
| 
 | ||||
|     // SET PIC FILENAME
 | ||||
|     if (fileName != "") | ||||
|     { | ||||
|         picFileName = fileName; | ||||
|  | @ -77,7 +87,7 @@ bool SnapmaticPicture::readingPicture() | |||
|     QByteArray jpegHeaderLine = picFile->read(jpegPreHeaderLength); | ||||
| 
 | ||||
|     // Checking for JPEG
 | ||||
|     jpegHeaderLine.remove(0,2); | ||||
|     jpegHeaderLine.remove(0, jpegHeaderLineDifStr); | ||||
|     if (jpegHeaderLine.left(4) != "JPEG") | ||||
|     { | ||||
|         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("z")) { jsonLocZ = locMap["z"].toDouble(); } | ||||
|     } | ||||
|     if (jsonMap.contains("crewid")) | ||||
|     { | ||||
|         jsonCrewID = jsonMap["crewid"].toInt(); | ||||
|     } | ||||
|     if (jsonMap.contains("plyrs")) | ||||
|     { | ||||
|         jsonPlyrsList = jsonMap["plyrs"].toStringList(); | ||||
|  | @ -194,6 +208,11 @@ QString SnapmaticPicture::getJsonStr() | |||
|     return jsonStr; | ||||
| } | ||||
| 
 | ||||
| int SnapmaticPicture::getCrewNumber() | ||||
| { | ||||
|     return jsonCrewID; | ||||
| } | ||||
| 
 | ||||
| double SnapmaticPicture::getLocationX() | ||||
| { | ||||
|     return jsonLocX; | ||||
|  |  | |||
|  | @ -39,6 +39,7 @@ public: | |||
|     QString getPictureStr(); | ||||
| 
 | ||||
|     // JSON
 | ||||
|     int getCrewNumber(); | ||||
|     QString getJsonStr(); | ||||
|     double getLocationX(); | ||||
|     double getLocationY(); | ||||
|  | @ -55,8 +56,17 @@ private: | |||
|     QString pictureStr; | ||||
|     QString lastStep; | ||||
| 
 | ||||
|     // PARSE INT
 | ||||
|     int snapmaticHeaderLength; | ||||
|     int snapmaticUsefulLength; | ||||
|     int jpegHeaderLineDifStr; | ||||
|     int jpegPreHeaderLength; | ||||
|     int jpegPicStreamLength; | ||||
|     int jsonStreamLength; | ||||
| 
 | ||||
|     // JSON
 | ||||
|     void parseJsonContent(); | ||||
|     int jsonCrewID; | ||||
|     QString jsonStr; | ||||
|     double jsonLocX; | ||||
|     double jsonLocY; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue