Rewrite of SnapmaticProperties
This commit is contained in:
		
							parent
							
								
									601552dc26
								
							
						
					
					
						commit
						ac40a0d194
					
				
					 6 changed files with 58 additions and 100 deletions
				
			
		|  | @ -265,14 +265,14 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu | |||
|     } | ||||
|     if (picture->isJsonOk()) | ||||
|     { | ||||
|         locX = QString::number(picture->getLocationX()); | ||||
|         locY = QString::number(picture->getLocationY()); | ||||
|         locZ = QString::number(picture->getLocationZ()); | ||||
|         crewID = crewDB->getCrewName(picture->getCrewNumber()); | ||||
|         created = picture->getCreatedDateTime().toString(Qt::DefaultLocaleShortDate); | ||||
|         plyrsList = picture->getPlayers(); | ||||
|         locX = QString::number(picture->getSnapmaticProperties().location.x); | ||||
|         locY = QString::number(picture->getSnapmaticProperties().location.y); | ||||
|         locZ = QString::number(picture->getSnapmaticProperties().location.z); | ||||
|         crewID = crewDB->getCrewName(picture->getSnapmaticProperties().crewID); | ||||
|         created = picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate); | ||||
|         plyrsList = picture->getSnapmaticProperties().playersList; | ||||
|         picTitl = picture->getPictureTitl(); | ||||
|         picArea = picture->getArea(); | ||||
|         picArea = picture->getSnapmaticProperties().area; | ||||
|         if (globalMap.contains(picArea)) | ||||
|         { | ||||
|             picAreaStr = globalMap[picArea]; | ||||
|  |  | |||
|  | @ -74,7 +74,7 @@ void ProfileLoader::run() | |||
|         if (picture->readingPicture()) | ||||
|         { | ||||
|             emit pictureLoaded(picture, picturePath); | ||||
|             int crewNumber = picture->getCrewNumber(); | ||||
|             int crewNumber = picture->getSnapmaticProperties().crewID; | ||||
|             if (!crewList.contains(crewNumber)) | ||||
|             { | ||||
|                 crewList.append(crewNumber); | ||||
|  |  | |||
|  | @ -60,18 +60,6 @@ SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : Q | |||
|     // INIT JSON
 | ||||
|     jsonOk = 0; | ||||
|     jsonStr = ""; | ||||
|     jsonLocX = 0; | ||||
|     jsonLocY = 0; | ||||
|     jsonLocZ = 0; | ||||
|     jsonCrewID = 0; | ||||
|     jsonArea = ""; | ||||
|     jsonCreatedTimestamp = 0; | ||||
|     jsonPlyrsList = QStringList(); | ||||
|     jsonMeme = 0; | ||||
|     jsonMug = 0; | ||||
|     jsonSelfie = 0; | ||||
|     jsonDirector = 0; | ||||
|     jsonRockstarEditor = 0; | ||||
| } | ||||
| 
 | ||||
| SnapmaticPicture::~SnapmaticPicture() | ||||
|  | @ -484,54 +472,52 @@ void SnapmaticPicture::parseJsonContent() | |||
| { | ||||
|     QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonStr.toLatin1()); | ||||
|     QJsonObject jsonObject = jsonDocument.object(); | ||||
|     QVariantMap jsonMap = jsonObject.toVariantMap(); | ||||
| 
 | ||||
|     if (jsonMap.contains("loc")) | ||||
|     if (jsonObject.contains("loc")) | ||||
|     { | ||||
|         QJsonObject locObject = jsonObject["loc"].toObject(); | ||||
|         QVariantMap locMap = locObject.toVariantMap(); | ||||
|         if (locMap.contains("x")) { jsonLocX = locMap["x"].toDouble(); } | ||||
|         if (locMap.contains("y")) { jsonLocY = locMap["y"].toDouble(); } | ||||
|         if (locMap.contains("z")) { jsonLocZ = locMap["z"].toDouble(); } | ||||
|         if (locObject.contains("x")) { localSpJson.location.x = locObject["x"].toDouble(); } | ||||
|         if (locObject.contains("y")) { localSpJson.location.y = locObject["y"].toDouble(); } | ||||
|         if (locObject.contains("z")) { localSpJson.location.z = locObject["z"].toDouble(); } | ||||
|     } | ||||
|     if (jsonMap.contains("area")) | ||||
|     if (jsonObject.contains("area")) | ||||
|     { | ||||
|         jsonArea = jsonMap["area"].toString(); | ||||
|         localSpJson.area = jsonObject["area"].toString(); | ||||
|     } | ||||
|     if (jsonMap.contains("crewid")) | ||||
|     if (jsonObject.contains("crewid")) | ||||
|     { | ||||
|         jsonCrewID = jsonMap["crewid"].toInt(); | ||||
|         localSpJson.crewID = jsonObject["crewid"].toInt(); | ||||
|     } | ||||
|     if (jsonMap.contains("creat")) | ||||
|     if (jsonObject.contains("creat")) | ||||
|     { | ||||
|         QDateTime createdTimestamp; | ||||
|         jsonCreatedTimestamp = jsonMap["creat"].toUInt(); | ||||
|         createdTimestamp.setTime_t(jsonCreatedTimestamp); | ||||
|         jsonCreatedDateTime = createdTimestamp; | ||||
|         localSpJson.createdTimestamp = jsonObject["creat"].toVariant().toUInt(); | ||||
|         createdTimestamp.setTime_t(localSpJson.createdTimestamp); | ||||
|         localSpJson.createdDateTime = createdTimestamp; | ||||
|     } | ||||
|     if (jsonMap.contains("plyrs")) | ||||
|     if (jsonObject.contains("plyrs")) | ||||
|     { | ||||
|         jsonPlyrsList = jsonMap["plyrs"].toStringList(); | ||||
|         localSpJson.playersList = jsonObject["plyrs"].toVariant().toStringList(); | ||||
|     } | ||||
|     if (jsonMap.contains("meme")) | ||||
|     if (jsonObject.contains("meme")) | ||||
|     { | ||||
|         jsonMeme = jsonMap["meme"].toBool(); | ||||
|         localSpJson.isMeme = jsonObject["meme"].toBool(); | ||||
|     } | ||||
|     if (jsonMap.contains("mug")) | ||||
|     if (jsonObject.contains("mug")) | ||||
|     { | ||||
|         jsonMug = jsonMap["mug"].toBool(); | ||||
|         localSpJson.isMug = jsonObject["mug"].toBool(); | ||||
|     } | ||||
|     if (jsonMap.contains("slf")) | ||||
|     if (jsonObject.contains("slf")) | ||||
|     { | ||||
|         jsonSelfie = jsonMap["slf"].toBool(); | ||||
|         localSpJson.isSelfie = jsonObject["slf"].toBool(); | ||||
|     } | ||||
|     if (jsonMap.contains("drctr")) | ||||
|     if (jsonObject.contains("drctr")) | ||||
|     { | ||||
|         jsonDirector = jsonMap["drctr"].toBool(); | ||||
|         localSpJson.isFromDirector = jsonObject["drctr"].toBool(); | ||||
|     } | ||||
|     if (jsonMap.contains("rsedtr")) | ||||
|     if (jsonObject.contains("rsedtr")) | ||||
|     { | ||||
|         jsonRockstarEditor = jsonMap["rsedtr"].toBool(); | ||||
|         localSpJson.isFromRSEditor = jsonObject["rsedtr"].toBool(); | ||||
|     } | ||||
| 
 | ||||
|     jsonOk = true; | ||||
|  | @ -542,44 +528,14 @@ bool SnapmaticPicture::isJsonOk() | |||
|     return jsonOk; | ||||
| } | ||||
| 
 | ||||
| QString SnapmaticPicture::getArea() | ||||
| { | ||||
|     return jsonArea; | ||||
| } | ||||
| 
 | ||||
| QString SnapmaticPicture::getJsonStr() | ||||
| { | ||||
|     return jsonStr; | ||||
| } | ||||
| 
 | ||||
| int SnapmaticPicture::getCrewNumber() | ||||
| SnapmaticProperties SnapmaticPicture::getSnapmaticProperties() | ||||
| { | ||||
|     return jsonCrewID; | ||||
| } | ||||
| 
 | ||||
| double SnapmaticPicture::getLocationX() | ||||
| { | ||||
|     return jsonLocX; | ||||
| } | ||||
| 
 | ||||
| double SnapmaticPicture::getLocationY() | ||||
| { | ||||
|     return jsonLocY; | ||||
| } | ||||
| 
 | ||||
| double SnapmaticPicture::getLocationZ() | ||||
| { | ||||
|     return jsonLocZ; | ||||
| } | ||||
| 
 | ||||
| QStringList SnapmaticPicture::getPlayers() | ||||
| { | ||||
|     return jsonPlyrsList; | ||||
| } | ||||
| 
 | ||||
| QDateTime SnapmaticPicture::getCreatedDateTime() | ||||
| { | ||||
|     return jsonCreatedDateTime; | ||||
|     return localSpJson; | ||||
| } | ||||
| 
 | ||||
| // VISIBILITY
 | ||||
|  |  | |||
|  | @ -26,6 +26,25 @@ | |||
| #include <QImage> | ||||
| #include <QFile> | ||||
| 
 | ||||
| struct SnapmaticProperties { | ||||
|     struct SnapmaticLocation { | ||||
|         double x; | ||||
|         double y; | ||||
|         double z; | ||||
|     }; | ||||
|     int crewID; | ||||
|     QString area; | ||||
|     QStringList playersList; | ||||
|     uint createdTimestamp; | ||||
|     QDateTime createdDateTime; | ||||
|     bool isMeme; | ||||
|     bool isMug; | ||||
|     bool isSelfie; | ||||
|     bool isFromDirector; | ||||
|     bool isFromRSEditor; | ||||
|     SnapmaticLocation location; | ||||
| }; | ||||
| 
 | ||||
| class SnapmaticPicture : public QObject | ||||
| { | ||||
|     Q_OBJECT | ||||
|  | @ -51,13 +70,8 @@ public: | |||
| 
 | ||||
|     // JSON
 | ||||
|     bool isJsonOk(); | ||||
|     QString getArea(); | ||||
|     int getCrewNumber(); | ||||
|     QString getJsonStr(); | ||||
|     double getLocationX(); | ||||
|     double getLocationY(); | ||||
|     double getLocationZ(); | ||||
|     QStringList getPlayers(); | ||||
|     SnapmaticProperties getSnapmaticProperties(); | ||||
| 
 | ||||
|     // VISIBILITY
 | ||||
|     bool isHidden(); | ||||
|  | @ -98,22 +112,10 @@ private: | |||
|     QByteArray rawPicContent; | ||||
| 
 | ||||
|     // JSON
 | ||||
|     void parseJsonContent(); | ||||
|     bool jsonOk; | ||||
|     int jsonCrewID; | ||||
|     QString jsonStr; | ||||
|     double jsonLocX; | ||||
|     double jsonLocY; | ||||
|     double jsonLocZ; | ||||
|     QString jsonArea; | ||||
|     QStringList jsonPlyrsList; | ||||
|     uint jsonCreatedTimestamp; | ||||
|     QDateTime jsonCreatedDateTime; | ||||
|     bool jsonMeme; | ||||
|     bool jsonMug; | ||||
|     bool jsonSelfie; | ||||
|     bool jsonDirector; | ||||
|     bool jsonRockstarEditor; | ||||
|     void parseJsonContent(); | ||||
|     SnapmaticProperties localSpJson; | ||||
| 
 | ||||
| signals: | ||||
| 
 | ||||
|  |  | |||
|  | @ -407,7 +407,7 @@ void UserInterface::openSnapmaticFile(SnapmaticPicture *picture) | |||
|     picDialog->setSnapmaticPicture(picture, true); | ||||
|     picDialog->setModal(true); | ||||
| 
 | ||||
|     int crewID = picture->getCrewNumber(); | ||||
|     int crewID = picture->getSnapmaticProperties().crewID; | ||||
|     if (crewID != 0) { crewDB->addCrew(crewID); } | ||||
| 
 | ||||
|     QObject::connect(threadDB, SIGNAL(playerNameFound(int, QString)), profileDB, SLOT(setPlayerName(int, QString))); | ||||
|  |  | |||
							
								
								
									
										2
									
								
								main.cpp
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								main.cpp
									
										
									
									
									
								
							|  | @ -435,7 +435,7 @@ int main(int argc, char *argv[]) | |||
|         picDialog->setWindowIcon(IconLoader::loadingAppIcon()); | ||||
|         picDialog->setSnapmaticPicture(&picture, readOk); | ||||
| 
 | ||||
|         int crewID = picture.getCrewNumber(); | ||||
|         int crewID = picture.getSnapmaticProperties().crewID; | ||||
|         if (crewID != 0) { crewDB->addCrew(crewID); } | ||||
|         if (!readOk) { return 1; } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue