From 24b1f32bbe1694c7cbbe418c0d7ba2ac8086f7a8 Mon Sep 17 00:00:00 2001 From: Syping Date: Wed, 1 Mar 2017 15:19:40 +0100 Subject: [PATCH] first development version of 1.4.x --- AboutDialog.cpp | 12 +- DatabaseThread.cpp | 4 - ImportDialog.cpp | 46 +- ImportDialog.h | 1 + ImportDialog.ui | 9 +- OptionsDialog.cpp | 4 + PictureDialog.cpp | 13 +- PictureExport.cpp | 24 +- ProfileInterface.cpp | 50 +- ProfileInterface.h | 4 +- SavegameCopy.cpp | 10 +- SavegameData.cpp | 8 +- SavegameData.h | 4 - SavegameDialog.cpp | 4 + SnapmaticEditor.cpp | 50 ++ SnapmaticEditor.h | 3 + SnapmaticEditor.ui | 57 ++- SnapmaticPicture.cpp | 167 ++++--- SnapmaticPicture.h | 14 +- SnapmaticWidget.cpp | 26 +- SnapmaticWidget.h | 2 + StringParser.cpp | 10 + StringParser.h | 1 + UserInterface.cpp | 40 +- config.h | 4 +- lang/README.txt | 10 +- lang/gta5sync_ru.ts | 653 ++++++++++++++++---------- main.cpp | 1 - qjson4/QJsonArray | 2 +- qjson4/QJsonArray.cpp | 820 ++++++++++++++++----------------- qjson4/QJsonArray.h | 278 +++++------ qjson4/QJsonDocument | 2 +- qjson4/QJsonDocument.cpp | 834 ++++++++++++++++----------------- qjson4/QJsonDocument.h | 206 ++++----- qjson4/QJsonObject | 2 +- qjson4/QJsonObject.cpp | 644 +++++++++++++------------- qjson4/QJsonObject.h | 242 +++++----- qjson4/QJsonParseError | 2 +- qjson4/QJsonParseError.cpp | 128 +++--- qjson4/QJsonParseError.h | 120 ++--- qjson4/QJsonParser.cpp | 910 ++++++++++++++++++------------------- qjson4/QJsonParser.h | 162 +++---- qjson4/QJsonRoot | 2 +- qjson4/QJsonRoot.h | 90 ++-- qjson4/QJsonValue | 2 +- qjson4/QJsonValue.cpp | 782 +++++++++++++++---------------- qjson4/QJsonValue.h | 240 +++++----- qjson4/QJsonValueRef | 2 +- qjson4/QJsonValueRef.cpp | 456 +++++++++---------- qjson4/QJsonValueRef.h | 158 +++---- res/app.rc | 8 +- res/avatarareaimport.png | Bin 2380 -> 2393 bytes res/global.de.ini | 204 ++++----- res/global.en.ini | 206 ++++----- res/global.es.ini | 214 ++++----- res/global.fr.ini | 206 ++++----- res/global.ja.ini | 212 ++++----- res/global.zh.ini | 208 ++++----- res/gta5sync_de.qm | Bin 29036 -> 29579 bytes res/gta5sync_de.ts | 267 ++++++----- res/gta5sync_fr.ts | 289 +++++++----- uimod/UiModLabel.cpp | 9 +- uimod/UiModLabel.h | 4 +- 63 files changed, 4792 insertions(+), 4350 deletions(-) diff --git a/AboutDialog.cpp b/AboutDialog.cpp index 7b1747e..871d21a 100755 --- a/AboutDialog.cpp +++ b/AboutDialog.cpp @@ -25,9 +25,10 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog) { - ui->setupUi(this); - aboutStr = ui->labAbout->text(); - titleStr = this->windowTitle(); + // Set Window Flags + setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); + + // Build Strings QString appVersion = qApp->applicationVersion(); QString buildType = GTA5SYNC_BUILDTYPE; buildType.replace("_", " "); @@ -38,6 +39,11 @@ AboutDialog::AboutDialog(QWidget *parent) : #else QString projectDes = tr("A project for viewing Grand Theft Auto V Snapmatic
\nPictures and Savegames"); #endif + + // Setup User Interface + ui->setupUi(this); + aboutStr = ui->labAbout->text(); + titleStr = this->windowTitle(); ui->labAbout->setText(aboutStr.arg(appVersion % " (" % buildType % ")", buildStr, qVersion(), projectBuild, GTA5SYNC_APPVENDORLINK, GTA5SYNC_APPVENDOR, GTA5SYNC_COPYRIGHT, GTA5SYNC_APPSTR, projectDes)); this->setWindowTitle(titleStr.arg(GTA5SYNC_APPSTR)); diff --git a/DatabaseThread.cpp b/DatabaseThread.cpp index 6889912..4273b0d 100755 --- a/DatabaseThread.cpp +++ b/DatabaseThread.cpp @@ -150,9 +150,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay) waitingLoop->exec(); delete waitingLoop; - netReply->deleteLater(); delete netReply; - netManager->deleteLater(); delete netManager; } } @@ -224,9 +222,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int currentPage++; } - netReply->deleteLater(); delete netReply; - netManager->deleteLater(); delete netManager; } } diff --git a/ImportDialog.cpp b/ImportDialog.cpp index e8d2ac6..ebce66c 100644 --- a/ImportDialog.cpp +++ b/ImportDialog.cpp @@ -23,6 +23,15 @@ #include #include +// IMAGES VALUES +#define snapmaticResolutionW 960 +#define snapmaticResolutionH 536 +#define snapmaticResolutionLW 430 +#define snapmaticResolutionLH 240 +#define snapmaticAvatarResolution 470 +#define snapmaticAvatarPlacementW 145 +#define snapmaticAvatarPlacementH 66 + ImportDialog::ImportDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ImportDialog) @@ -51,7 +60,7 @@ ImportDialog::~ImportDialog() void ImportDialog::processImage() { QImage snapmaticImage = workImage; - QPixmap snapmaticPixmap(960, 536); + QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH); snapmaticPixmap.fill(Qt::black); QPainter snapmaticPainter(&snapmaticPixmap); if (ui->cbAvatar->isChecked()) @@ -61,24 +70,23 @@ void ImportDialog::processImage() int diffHeight = 0; if (ui->rbKeep->isChecked()) { - snapmaticImage = snapmaticImage.scaled(470, 470, Qt::KeepAspectRatio, Qt::SmoothTransformation); + snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation); if (snapmaticImage.width() > snapmaticImage.height()) { - diffHeight = 470 - snapmaticImage.height(); + diffHeight = snapmaticAvatarResolution - snapmaticImage.height(); diffHeight = diffHeight / 2; } else if (snapmaticImage.width() < snapmaticImage.height()) { - diffWidth = 470 - snapmaticImage.width(); + diffWidth = snapmaticAvatarResolution - snapmaticImage.width(); diffWidth = diffWidth / 2; } } else { - snapmaticImage = snapmaticImage.scaled(470, 470, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } - snapmaticPainter.drawImage(0, 0, avatarAreaImage); - snapmaticPainter.drawImage(145 + diffWidth, 66 + diffHeight, snapmaticImage); + snapmaticPainter.drawImage(snapmaticAvatarPlacementW + diffWidth, snapmaticAvatarPlacementH + diffHeight, snapmaticImage); imageTitle = "Custom Avatar"; } else @@ -88,28 +96,28 @@ void ImportDialog::processImage() int diffHeight = 0; if (ui->rbKeep->isChecked()) { - snapmaticImage = snapmaticImage.scaled(960, 536, Qt::KeepAspectRatio, Qt::SmoothTransformation); - if (snapmaticImage.width() != 960) + snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation); + if (snapmaticImage.width() != snapmaticResolutionW) { - diffWidth = 960 - snapmaticImage.width(); + diffWidth = snapmaticResolutionW - snapmaticImage.width(); diffWidth = diffWidth / 2; } - else if (snapmaticImage.height() != 536) + else if (snapmaticImage.height() != snapmaticResolutionH) { - diffHeight = 536 - snapmaticImage.height(); + diffHeight = snapmaticResolutionH - snapmaticImage.height(); diffHeight = diffHeight / 2; } } else { - snapmaticImage = snapmaticImage.scaled(960, 536, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, snapmaticImage); imageTitle = "Custom Picture"; } snapmaticPainter.end(); newImage = snapmaticPixmap.toImage(); - ui->labPicture->setPixmap(snapmaticPixmap.scaled(430, 240, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + ui->labPicture->setPixmap(snapmaticPixmap.scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } QImage ImportDialog::image() @@ -162,3 +170,13 @@ void ImportDialog::on_cmdOK_clicked() doImport = true; close(); } + +void ImportDialog::on_labPicture_labelPainted() +{ + if (ui->cbAvatar->isChecked()) + { + QPainter labelPainter(ui->labPicture); + labelPainter.drawImage(0, 0, avatarAreaImage.scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + labelPainter.end(); + } +} diff --git a/ImportDialog.h b/ImportDialog.h index ae4b72b..0503dd3 100644 --- a/ImportDialog.h +++ b/ImportDialog.h @@ -44,6 +44,7 @@ private slots: void on_cbAvatar_clicked(); void on_cmdCancel_clicked(); void on_cmdOK_clicked(); + void on_labPicture_labelPainted(); private: Ui::ImportDialog *ui; diff --git a/ImportDialog.ui b/ImportDialog.ui index 231c71a..dc42083 100644 --- a/ImportDialog.ui +++ b/ImportDialog.ui @@ -42,7 +42,7 @@ 0 - + 430 @@ -175,6 +175,13 @@ + + + UiModLabel + QLabel +
UiModLabel.h
+
+
diff --git a/OptionsDialog.cpp b/OptionsDialog.cpp index 41a761e..68bc8f9 100755 --- a/OptionsDialog.cpp +++ b/OptionsDialog.cpp @@ -37,6 +37,10 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) : QDialog(parent), profileDB(profileDB), ui(new Ui::OptionsDialog) { + // Set Window Flags + setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); + + // Setup User Interface ui->setupUi(this); ui->tabWidget->setCurrentIndex(0); ui->labPicCustomRes->setVisible(false); diff --git a/PictureDialog.cpp b/PictureDialog.cpp index f21d8a0..dca0ef3 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -23,6 +23,7 @@ #include "SidebarGenerator.h" #include "StandardPaths.h" #include "PictureExport.h" +#include "StringParser.h" #include "GlobalString.h" #include "UiModLabel.h" @@ -89,6 +90,10 @@ PictureDialog::PictureDialog(bool primaryWindow, QWidget *parent) : void PictureDialog::setupPictureDialog(bool withDatabase_) { + // Set Window Flags + setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); + + // Setup User Interface ui->setupUi(this); windowTitleStr = this->windowTitle(); jsonDrawString = ui->labJSON->text(); @@ -422,7 +427,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, } created = picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate); plyrsList = picture->getSnapmaticProperties().playersList; - picTitl = picture->getPictureTitl(); + picTitl = StringParser::escapeString(picture->getPictureTitle()); picArea = picture->getSnapmaticProperties().location.area; if (globalMap.contains(picArea)) { @@ -596,7 +601,7 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button) if (button == Qt::LeftButton) { QRect desktopRect = QApplication::desktop()->screenGeometry(this); - PictureWidget *pictureWidget = new PictureWidget(this); + PictureWidget *pictureWidget = new PictureWidget(this); // Work! pictureWidget->setObjectName("PictureWidget"); #if QT_VERSION >= 0x050600 pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::WindowStaysOnTopHint^Qt::MaximizeUsingFullscreenGeometryHint); @@ -620,8 +625,8 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button) pictureWidget->raise(); pictureWidget->exec(); - fullscreenWidget = 0; - delete pictureWidget; + fullscreenWidget = 0; // Work! + delete pictureWidget; // Work! } } diff --git a/PictureExport.cpp b/PictureExport.cpp index df23f72..3a25d26 100755 --- a/PictureExport.cpp +++ b/PictureExport.cpp @@ -76,7 +76,7 @@ void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture) settings.beginGroup("FileDialogs"); settings.beginGroup("ExportAsPicture"); -fileDialogPreSave: +fileDialogPreSave: //Work? QFileDialog fileDialog(parent); fileDialog.setFileMode(QFileDialog::AnyFile); fileDialog.setViewMode(QFileDialog::Detail); @@ -145,12 +145,12 @@ fileDialogPreSave: if (!QFile::remove(selectedFile)) { QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\"")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } else { - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } @@ -179,13 +179,13 @@ fileDialogPreSave: if (!isSaved) { QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Failed to export current Snapmatic picture")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } else { QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("No valid file is selected")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } @@ -207,7 +207,7 @@ void PictureExport::exportAsSnapmatic(QWidget *parent, SnapmaticPicture *picture adjustedPicPath.remove(adjustedPicPath.length() - 7, 7); } -fileDialogPreSave: +fileDialogPreSave: //Work? QFileInfo sgdFileInfo(adjustedPicPath); QFileDialog fileDialog(parent); fileDialog.setFileMode(QFileDialog::AnyFile); @@ -218,7 +218,7 @@ fileDialogPreSave: fileDialog.setDefaultSuffix(".rem"); fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint); fileDialog.setWindowTitle(PictureDialog::tr("Export as GTA Snapmatic...")); - fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("&Export")); + fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export")); QStringList filters; filters << PictureDialog::tr("GTA V Export (*.g5e)"); @@ -248,12 +248,12 @@ fileDialogPreSave: if (!QFile::remove(selectedFile)) { QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\"")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } else { - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } @@ -263,7 +263,7 @@ fileDialogPreSave: if (!isExported) { QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } else @@ -284,7 +284,7 @@ fileDialogPreSave: if (!isCopied) { QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } else { @@ -295,7 +295,7 @@ fileDialogPreSave: else { QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("No valid file is selected")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 4ce95af..4cb0929 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -79,22 +80,18 @@ ProfileInterface::~ProfileInterface() foreach(ProfileWidget *widget, widgets.keys()) { widgets.remove(widget); - widget->deleteLater(); delete widget; } foreach(SavegameData *savegame, savegames) { savegames.removeAll(savegame); - savegame->deleteLater(); delete savegame; } foreach(SnapmaticPicture *picture, pictures) { pictures.removeAll(picture); - picture->deleteLater(); delete picture; } - profileLoader->deleteLater(); delete profileLoader; delete ui; @@ -318,32 +315,50 @@ void ProfileInterface::profileLoaded_p() void ProfileInterface::savegameDeleted_event() { - savegameDeleted((SavegameWidget*)sender()); + savegameDeleted((SavegameWidget*)sender(), true); } -void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget) +void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited) { SavegameData *savegame = sgdWidget->getSavegame(); if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); } widgets.remove(sgdWidget); - sgdWidget->close(); - sgdWidget->deleteLater(); + + // Deleting when the widget did send a event cause a crash + if (isRemoteEmited) + { + sgdWidget->deleteLater(); + } + else + { + delete sgdWidget; + } + savegames.removeAll(savegame); delete savegame; } void ProfileInterface::pictureDeleted_event() { - pictureDeleted((SnapmaticWidget*)sender()); + pictureDeleted((SnapmaticWidget*)sender(), true); } -void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget) +void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited) { SnapmaticPicture *picture = picWidget->getPicture(); if (picWidget->isSelected()) { picWidget->setSelected(false); } widgets.remove(picWidget); - picWidget->close(); - picWidget->deleteLater(); + + // Deleting when the widget did send a event cause a crash + if (isRemoteEmited) + { + picWidget->deleteLater(); + } + else + { + delete picWidget; + } + pictures.removeAll(picture); delete picture; } @@ -359,7 +374,7 @@ void ProfileInterface::on_cmdImport_clicked() settings.beginGroup("FileDialogs"); settings.beginGroup("ImportCopy"); -fileDialogPreOpen: +fileDialogPreOpen: //Work? QFileDialog fileDialog(this); fileDialog.setFileMode(QFileDialog::ExistingFiles); fileDialog.setViewMode(QFileDialog::Detail); @@ -390,7 +405,7 @@ fileDialogPreOpen: if (selectedFiles.length() == 1) { QString selectedFile = selectedFiles.at(0); - if (!importFile(selectedFile, true, 0)) goto fileDialogPreOpen; + if (!importFile(selectedFile, true, 0)) goto fileDialogPreOpen; //Work? } else if (selectedFiles.length() > 1) { @@ -463,7 +478,7 @@ fileDialogPreOpen: else { QMessageBox::warning(this, tr("Import"), tr("No valid file is selected")); - goto fileDialogPreOpen; + goto fileDialogPreOpen; //Work? } } @@ -920,7 +935,6 @@ void ProfileInterface::exportSelected() if (exportThread->isFinished()) { - exportThread->deleteLater(); delete exportThread; } else @@ -928,7 +942,6 @@ void ProfileInterface::exportSelected() QEventLoop threadFinishLoop; QObject::connect(exportThread, SIGNAL(finished()), &threadFinishLoop, SLOT(quit())); threadFinishLoop.exec(); - exportThread->deleteLater(); delete exportThread; } } @@ -954,8 +967,7 @@ void ProfileInterface::deleteSelected() if (widget->getWidgetType() == "SnapmaticWidget") { SnapmaticWidget *picWidget = (SnapmaticWidget*)widget; - QString fileName = picWidget->getPicturePath(); - if (!QFile::exists(fileName) || QFile::remove(fileName)) + if (picWidget->getPicture()->deletePicFile()) { pictureDeleted(picWidget); } diff --git a/ProfileInterface.h b/ProfileInterface.h index 8150d5c..3ae93cc 100755 --- a/ProfileInterface.h +++ b/ProfileInterface.h @@ -98,8 +98,8 @@ private: bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true); void pictureLoaded(SnapmaticPicture *picture, bool inserted); void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted); - void savegameDeleted(SavegameWidget *sgdWidget); - void pictureDeleted(SnapmaticWidget *picWidget); + void savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited = false); + void pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited = false); void insertSnapmaticIPI(QWidget *widget); void insertSavegameIPI(QWidget *widget); void sortingProfileInterface(); diff --git a/SavegameCopy.cpp b/SavegameCopy.cpp index f1e0018..fc0e3e0 100755 --- a/SavegameCopy.cpp +++ b/SavegameCopy.cpp @@ -34,7 +34,7 @@ void SavegameCopy::copySavegame(QWidget *parent, QString sgdPath) QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); settings.beginGroup("FileDialogs"); -fileDialogPreSave: +fileDialogPreSave: //Work? QFileInfo sgdFileInfo(sgdPath); QFileDialog fileDialog(parent); fileDialog.setFileMode(QFileDialog::AnyFile); @@ -72,12 +72,12 @@ fileDialogPreSave: if (!QFile::remove(selectedFile)) { QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Failed to overwrite %1 with current Savegame").arg("\""+selectedFile+"\"")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } else { - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } @@ -85,13 +85,13 @@ fileDialogPreSave: if (!isCopied) { QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Failed to export current Savegame")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } else { QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("No valid file is selected")); - goto fileDialogPreSave; + goto fileDialogPreSave; //Work? } } diff --git a/SavegameData.cpp b/SavegameData.cpp index c88a6d7..b679325 100755 --- a/SavegameData.cpp +++ b/SavegameData.cpp @@ -19,15 +19,15 @@ #include "StringParser.h" #include "SavegameData.h" #include +#include #include #include +#define savegameHeaderLength 260 +#define verificationValue QByteArray::fromHex("00000001") + SavegameData::SavegameData(const QString &fileName, QObject *parent) : QObject(parent), savegameFileName(fileName) { - // PARSE INT INIT - DO NOT CHANGE THIS VALUES - savegameHeaderLength = 260; - verificationValue = QByteArray::fromHex("00000001"); - // INIT SAVEGAME savegameStr = ""; savegameOk = 0; diff --git a/SavegameData.h b/SavegameData.h index 2eae21e..20f87b3 100755 --- a/SavegameData.h +++ b/SavegameData.h @@ -40,10 +40,6 @@ private: QString savegameStr; QString lastStep; bool savegameOk; - - // PARSE INT - QByteArray verificationValue; - int savegameHeaderLength; }; #endif // SAVEGAMEDATA_H diff --git a/SavegameDialog.cpp b/SavegameDialog.cpp index 66c51f4..b9ee746 100755 --- a/SavegameDialog.cpp +++ b/SavegameDialog.cpp @@ -7,6 +7,10 @@ SavegameDialog::SavegameDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SavegameDialog) { + // Set Window Flags + setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); + + // Setup User Interface ui->setupUi(this); savegameLabStr = ui->labSavegameText->text(); diff --git a/SnapmaticEditor.cpp b/SnapmaticEditor.cpp index 28261c0..2daf948 100644 --- a/SnapmaticEditor.cpp +++ b/SnapmaticEditor.cpp @@ -19,6 +19,9 @@ #include "SnapmaticEditor.h" #include "ui_SnapmaticEditor.h" #include "SnapmaticPicture.h" +#include "StringParser.h" +#include +#include #include #include #include @@ -42,6 +45,7 @@ SnapmaticEditor::SnapmaticEditor(QWidget *parent) : ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel")); } + snapmaticTitle = ""; smpic = 0; } @@ -179,6 +183,30 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture) { ui->rbCustom->setChecked(true); } + setSnapmaticTitle(picture->getPictureTitle()); +} + +void SnapmaticEditor::setSnapmaticTitle(const QString &title) +{ + if (title.length() > 39) + { + snapmaticTitle = title.left(39); + } + else + { + snapmaticTitle = title; + } + QString editStr = QString("%1").arg(tr("Edit")); + QString titleStr = tr("Title: %1 (%2)").arg(StringParser::escapeString(snapmaticTitle), editStr); + ui->labTitle->setText(titleStr); + if (SnapmaticPicture::verifyTitle(snapmaticTitle)) + { + ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("%1").arg(tr("Yes", "Yes, should work fine")))); + } + else + { + ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("%1").arg(tr("No", "No, could lead to issues")))); + } } void SnapmaticEditor::on_cmdCancel_clicked() @@ -210,10 +238,19 @@ void SnapmaticEditor::on_cmdApply_clicked() { QFile::copy(adjustedFileName, backupFileName); } + SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties(); + QString fallbackTitle = smpic->getPictureTitle(); smpic->setSnapmaticProperties(localSpJson); + smpic->setPictureTitle(snapmaticTitle); if (!smpic->exportPicture(originalFileName)) { QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error")); + smpic->setSnapmaticProperties(fallbackProperties); + smpic->setPictureTitle(fallbackTitle); + } + else + { + smpic->emitUpdate(); } } close(); @@ -251,3 +288,16 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked) } } } + +void SnapmaticEditor::on_labTitle_linkActivated(const QString &link) +{ + if (link == "g5e://edittitle") + { + bool ok; + QString newTitle = QInputDialog::getText(this, tr("Snapmatic Title"), tr("New Snapmatic title:"), QLineEdit::Normal, snapmaticTitle, &ok, windowFlags()); + if (ok && !newTitle.isEmpty()) + { + setSnapmaticTitle(newTitle); + } + } +} diff --git a/SnapmaticEditor.h b/SnapmaticEditor.h index 895b26c..4a2d6f4 100644 --- a/SnapmaticEditor.h +++ b/SnapmaticEditor.h @@ -33,6 +33,7 @@ class SnapmaticEditor : public QDialog public: explicit SnapmaticEditor(QWidget *parent = 0); void setSnapmaticPicture(SnapmaticPicture *picture); + void setSnapmaticTitle(const QString &title); ~SnapmaticEditor(); private slots: @@ -47,11 +48,13 @@ private slots: void on_cmdCancel_clicked(); void on_cmdApply_clicked(); void on_cbQualify_toggled(bool checked); + void on_labTitle_linkActivated(const QString &link); private: Ui::SnapmaticEditor *ui; SnapmaticProperties localSpJson; SnapmaticPicture *smpic; + QString snapmaticTitle; void qualifyAvatar(); }; diff --git a/SnapmaticEditor.ui b/SnapmaticEditor.ui index 27dd512..0e361ff 100644 --- a/SnapmaticEditor.ui +++ b/SnapmaticEditor.ui @@ -6,8 +6,8 @@ 0 0 - 375 - 319 + 400 + 350 @@ -119,6 +119,50 @@ + + + + Snapmatic Title + + + + + + + 0 + 0 + + + + Qt::NoContextMenu + + + Title: %1 (%2) + + + true + + + + + + + + 0 + 0 + + + + Appropriate: %1 + + + true + + + + + + @@ -133,7 +177,7 @@ - + 0 @@ -212,6 +256,13 @@ + + + UiModLabel + QLabel +
UiModLabel.h
+
+
diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index 23201fb..ec7c737 100755 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include // PARSER ALLOCATIONS @@ -49,11 +50,13 @@ #define titlStreamEditorLength 256 #define titlStreamCharacterMax 39 +// IMAGES VALUES +#define snapmaticResolutionW 960 +#define snapmaticResolutionH 536 +#define snapmaticResolution QSize(snapmaticResolutionW, snapmaticResolutionH) + SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : QObject(parent), picFilePath(fileName) { - // PREDEFINED PROPERTIES - snapmaticResolution = QSize(960, 536); - reset(); } @@ -65,7 +68,7 @@ void SnapmaticPicture::reset() { // INIT PIC rawPicContent = ""; - cachePicture = QImage(0, 0, QImage::Format_RGB888); + cachePicture = QImage(); jpegRawContentSize = 0; picExportFileName = ""; isCustomFormat = 0; @@ -483,51 +486,6 @@ bool SnapmaticPicture::setPictureTitl(const QString &newTitle_) return false; } -bool SnapmaticPicture::exportPicture(const QString &fileName, bool customFormat) -{ - QFile *picFile = new QFile(fileName); - if (picFile->open(QIODevice::WriteOnly)) - { - if (!customFormat) - { - // Classic straight export - picFile->write(rawPicContent); - picFile->close(); - picFile->deleteLater(); - } - else - { - // Modern compressed export - QByteArray stockFileNameUTF8 = picFileName.toUtf8(); - QByteArray numberLength = QByteArray::number(stockFileNameUTF8.length()); - if (numberLength.length() == 1) - { - numberLength.insert(0, "0"); - } - else if (numberLength.length() != 2) - { - numberLength = "00"; - } - picFile->write(QByteArray::fromHex("00")); // First Null Byte - picFile->write("G5E"); // GTA 5 Export - picFile->write(QByteArray::fromHex("1000")); // 2 byte GTA 5 Export Version - picFile->write("LEN"); // Before Length - picFile->write(QByteArray::fromHex(numberLength)); // Length in HEX before Compressed - picFile->write("FIL"); // Before File Name - picFile->write(stockFileNameUTF8); // File Name - picFile->write("COM"); // Before Compressed - picFile->write(qCompress(rawPicContent, 9)); // Compressed Snapmatic - picFile->close(); - picFile->deleteLater(); - } - return true; - } - else - { - return false; - } -} - QString SnapmaticPicture::getExportPictureFileName() { return picExportFileName; @@ -655,24 +613,34 @@ bool SnapmaticPicture::isPicOk() return picOk; } -void SnapmaticPicture::setPicFileName(QString picFileName_) -{ - picFileName = picFileName_; -} - -void SnapmaticPicture::setPicFilePath(QString picFilePath_) -{ - picFilePath = picFilePath_; -} - void SnapmaticPicture::clearCache() { cacheEnabled = false; - cachePicture = QImage(0, 0, QImage::Format_RGB888); + cachePicture = QImage(); +} + +void SnapmaticPicture::emitUpdate() +{ + emit updated(); } // JSON part +bool SnapmaticPicture::isJsonOk() +{ + return jsonOk; +} + +QString SnapmaticPicture::getJsonStr() +{ + return jsonStr; +} + +SnapmaticProperties SnapmaticPicture::getSnapmaticProperties() +{ + return localSpJson; +} + void SnapmaticPicture::parseJsonContent() { QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonStr.toUtf8()); @@ -733,21 +701,6 @@ void SnapmaticPicture::parseJsonContent() jsonOk = true; } -bool SnapmaticPicture::isJsonOk() -{ - return jsonOk; -} - -QString SnapmaticPicture::getJsonStr() -{ - return jsonStr; -} - -SnapmaticProperties SnapmaticPicture::getSnapmaticProperties() -{ - return localSpJson; -} - bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson) { QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonStr.toUtf8()); @@ -811,6 +764,70 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson) return true; } +// FILE MANAGEMENT + +bool SnapmaticPicture::exportPicture(const QString &fileName, bool customFormat) +{ + QFile *picFile = new QFile(fileName); + if (picFile->open(QIODevice::WriteOnly)) + { + if (!customFormat) + { + // Classic straight export + picFile->write(rawPicContent); + picFile->close(); + picFile->deleteLater(); + } + else + { + // Modern compressed export + QByteArray stockFileNameUTF8 = picFileName.toUtf8(); + QByteArray numberLength = QByteArray::number(stockFileNameUTF8.length()); + if (numberLength.length() == 1) + { + numberLength.insert(0, "0"); + } + else if (numberLength.length() != 2) + { + numberLength = "00"; + } + picFile->write(QByteArray::fromHex("00")); // First Null Byte + picFile->write("G5E"); // GTA 5 Export + picFile->write(QByteArray::fromHex("1000")); // 2 byte GTA 5 Export Version + picFile->write("LEN"); // Before Length + picFile->write(QByteArray::fromHex(numberLength)); // Length in HEX before Compressed + picFile->write("FIL"); // Before File Name + picFile->write(stockFileNameUTF8); // File Name + picFile->write("COM"); // Before Compressed + picFile->write(qCompress(rawPicContent, 9)); // Compressed Snapmatic + picFile->close(); + picFile->deleteLater(); + } + return true; + } + else + { + return false; + } +} + +void SnapmaticPicture::setPicFileName(const QString &picFileName_) +{ + picFileName = picFileName_; +} + +void SnapmaticPicture::setPicFilePath(const QString &picFilePath_) +{ + picFilePath = picFilePath_; +} + +bool SnapmaticPicture::deletePicFile() +{ + if (!QFile::exists(picFilePath)) return true; + if (QFile::remove(picFilePath)) return true; + return false; +} + // VISIBILITY bool SnapmaticPicture::isHidden() diff --git a/SnapmaticPicture.h b/SnapmaticPicture.h index 034636b..37d8880 100755 --- a/SnapmaticPicture.h +++ b/SnapmaticPicture.h @@ -71,10 +71,14 @@ public: bool setImage(const QImage &picture); bool setPictureTitl(const QString &newTitle); bool setPictureStream(const QByteArray &picByteArray); - bool exportPicture(const QString &fileName, bool customFormat = false); - void setPicFileName(QString picFileName); - void setPicFilePath(QString picFilePath); void updateStrings(); + void emitUpdate(); + + // FILE MANAGEMENT + bool exportPicture(const QString &fileName, bool customFormat = false); + void setPicFileName(const QString &picFileName); + void setPicFilePath(const QString &picFilePath); + bool deletePicFile(); // ALTERNATIVES QString getPictureTitle() { return getPictureTitl(); } @@ -122,9 +126,6 @@ private: // PICTURE STREAM QByteArray rawPicContent; - // PREDEFINED PROPERTIES - QSize snapmaticResolution; - // JSON void parseJsonContent(); bool jsonOk; @@ -135,6 +136,7 @@ private: static bool verifyTitleChar(const QChar &titleChar); signals: + void updated(); public slots: }; diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index df592cd..c9fdc97 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -23,6 +23,7 @@ #include "DatabaseThread.h" #include "PictureDialog.h" #include "PictureExport.h" +#include "StringParser.h" #include "config.h" #include #include @@ -84,6 +85,7 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture) picPath = picture->getPictureFilePath(); picTitl = picture->getPictureTitl(); picStr = picture->getPictureStr(); + QObject::connect(picture, SIGNAL(updated()), this, SLOT(snapmaticUpdated())); QPixmap SnapmaticPixmap = QPixmap::fromImage(picture->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor); ui->labPicStr->setText(picStr + "\n" + picTitl + ""); @@ -94,6 +96,15 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture) adjustTextColor(); } +void SnapmaticWidget::snapmaticUpdated() +{ + // Current only strings get updated + picPath = smpic->getPictureFilePath(); + picTitl = smpic->getPictureTitl(); + picStr = smpic->getPictureStr(); + ui->labPicStr->setText(picStr + "\n" + picTitl + ""); +} + void SnapmaticWidget::on_cmdView_clicked() { QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); @@ -102,7 +113,6 @@ void SnapmaticWidget::on_cmdView_clicked() settings.endGroup(); PictureDialog *picDialog = new PictureDialog(profileDB, crewDB, this); - picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint); picDialog->setSnapmaticPicture(smpic, true); picDialog->setModal(true); @@ -135,23 +145,25 @@ void SnapmaticWidget::on_cmdExport_clicked() } void SnapmaticWidget::on_cmdDelete_clicked() +{ + if (deletePicture()) emit pictureDeleted(); +} + +bool SnapmaticWidget::deletePicture() { int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+picStr+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (uchoice == QMessageBox::Yes) { - if (!QFile::exists(picPath)) + if (smpic->deletePicFile()) { - emit pictureDeleted(); - } - else if(QFile::remove(picPath)) - { - emit pictureDeleted(); + return true; } else { QMessageBox::warning(this, tr("Delete picture"), tr("Failed at deleting %1 from your Snapmatic pictures").arg("\""+picStr+"\"")); } } + return false; } void SnapmaticWidget::mousePressEvent(QMouseEvent *ev) diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index 2e45d37..a25b638 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -42,6 +42,7 @@ public: void setSnapmaticPicture(SnapmaticPicture *picture); void setSelectionMode(bool selectionMode); void setSelected(bool isSelected); + bool deletePicture(); bool makePictureVisible(); bool makePictureHidden(); SnapmaticPicture *getPicture(); @@ -66,6 +67,7 @@ private slots: void makePictureVisibleSlot(); void makePictureHiddenSlot(); void editSnapmaticProperties(); + void snapmaticUpdated(); protected: bool eventFilter(QObject *obj, QEvent *ev); diff --git a/StringParser.cpp b/StringParser.cpp index 1c0f9c5..85ed417 100755 --- a/StringParser.cpp +++ b/StringParser.cpp @@ -18,6 +18,7 @@ #include "StringParser.h" #include "config.h" +#include #include #include #include @@ -60,3 +61,12 @@ QString StringParser::convertBuildedString(const QString &buildedStr) outputStr.replace("$SEPARATOR", QDir::separator()); return outputStr; } + +QString StringParser::escapeString(const QString &toEscape) +{ +#if QT_VERSION >= 0x050000 + return toEscape.toHtmlEscaped(); +#else + return Qt::escape(toEscape); +#endif +} diff --git a/StringParser.h b/StringParser.h index 8906fc8..3815a34 100755 --- a/StringParser.h +++ b/StringParser.h @@ -30,6 +30,7 @@ public: static QString convertDrawStringForLog(const QString &inputStr); static QString convertLogStringForDraw(const QString &inputStr); static QString convertBuildedString(const QString &buildedStr); + static QString escapeString(const QString &toEscape); }; #endif // STRINGPARSER_H diff --git a/UserInterface.cpp b/UserInterface.cpp index c1d67d0..0c51f88 100755 --- a/UserInterface.cpp +++ b/UserInterface.cpp @@ -208,7 +208,6 @@ void UserInterface::closeProfile() ui->menuProfile->setEnabled(false); ui->actionSelect_profile->setEnabled(false); ui->swProfile->removeWidget(profileUI); - profileUI->deleteLater(); delete profileUI; } this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile"))); @@ -248,11 +247,10 @@ void UserInterface::openSelectProfile() void UserInterface::on_actionAbout_gta5sync_triggered() { AboutDialog *aboutDialog = new AboutDialog(this); - aboutDialog->setWindowFlags(aboutDialog->windowFlags()^Qt::WindowContextHelpButtonHint); + aboutDialog->setWindowIcon(windowIcon()); aboutDialog->setModal(true); aboutDialog->show(); aboutDialog->exec(); - aboutDialog->deleteLater(); delete aboutDialog; } @@ -297,13 +295,14 @@ void UserInterface::on_actionDelete_selected_triggered() void UserInterface::on_actionOptions_triggered() { OptionsDialog *optionsDialog = new OptionsDialog(profileDB, this); - optionsDialog->setWindowFlags(optionsDialog->windowFlags()^Qt::WindowContextHelpButtonHint); + optionsDialog->setWindowIcon(windowIcon()); optionsDialog->commitProfiles(GTAV_Profiles); - QObject::connect(optionsDialog, SIGNAL(settingsApplied(int,QString)), this, SLOT(settingsApplied(int,QString))); + QObject::connect(optionsDialog, SIGNAL(settingsApplied(int, QString)), this, SLOT(settingsApplied(int, QString))); optionsDialog->setModal(true); optionsDialog->show(); optionsDialog->exec(); + delete optionsDialog; } @@ -428,35 +427,30 @@ bool UserInterface::openFile(QString selectedFile, bool warn) void UserInterface::openSnapmaticFile(SnapmaticPicture *picture) { - PictureDialog *picDialog = new PictureDialog(profileDB, crewDB, this); - picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint); - picDialog->setSnapmaticPicture(picture, true); - picDialog->setModal(true); + PictureDialog picDialog(profileDB, crewDB, this); + picDialog.setSnapmaticPicture(picture, true); + picDialog.setModal(true); int crewID = picture->getSnapmaticProperties().crewID; if (crewID != 0) { crewDB->addCrew(crewID); } QObject::connect(threadDB, SIGNAL(playerNameFound(int, QString)), profileDB, SLOT(setPlayerName(int, QString))); - QObject::connect(threadDB, SIGNAL(playerNameUpdated()), picDialog, SLOT(playerNameUpdated())); + QObject::connect(threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated())); - picDialog->show(); - picDialog->setMinimumSize(picDialog->size()); - picDialog->setMaximumSize(picDialog->size()); + picDialog.show(); + picDialog.setMinimumSize(picDialog.size()); + picDialog.setMaximumSize(picDialog.size()); - picDialog->exec(); - delete picDialog; + picDialog.exec(); } void UserInterface::openSavegameFile(SavegameData *savegame) { - SavegameDialog *sgdDialog = new SavegameDialog(this); - sgdDialog->setWindowFlags(sgdDialog->windowFlags()^Qt::WindowContextHelpButtonHint); - sgdDialog->setSavegameData(savegame, savegame->getSavegameFileName(), true); - sgdDialog->setModal(true); - - sgdDialog->show(); - sgdDialog->exec(); - delete sgdDialog; + SavegameDialog sgdDialog(this); + sgdDialog.setSavegameData(savegame, savegame->getSavegameFileName(), true); + sgdDialog.setModal(true); + sgdDialog.show(); + sgdDialog.exec(); } void UserInterface::settingsApplied(int _contentMode, QString _language) diff --git a/config.h b/config.h index 524652e..8e0020f 100755 --- a/config.h +++ b/config.h @@ -50,14 +50,14 @@ #ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_DAILYB -#define GTA5SYNC_APPVER "1.3.3" +#define GTA5SYNC_APPVER "1.4.0-dev1" #else #define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB) #endif #endif #ifndef GTA5SYNC_BUILDTYPE -#define GTA5SYNC_BUILDTYPE "Custom" +#define GTA5SYNC_BUILDTYPE "Developer" #endif #ifndef GTA5SYNC_SHARE diff --git a/lang/README.txt b/lang/README.txt index c21786f..f95afe5 100755 --- a/lang/README.txt +++ b/lang/README.txt @@ -1,5 +1,5 @@ -Community translation files - -They get loaded in ApplicationPathExecFileFolder/lang - -You can help translate with using Qt Linguist, after you've translated you'll need to send me a pull request on https://github.com/Syping/gta5sync +Community translation files + +They get loaded in ApplicationPathExecFileFolder/lang + +You can help translate with using Qt Linguist, after you've translated you'll need to send me a pull request on https://github.com/Syping/gta5sync diff --git a/lang/gta5sync_ru.ts b/lang/gta5sync_ru.ts index 3c855fb..bd2cb52 100755 --- a/lang/gta5sync_ru.ts +++ b/lang/gta5sync_ru.ts @@ -9,26 +9,25 @@ - About gta5view + About %1 - <span style=" font-weight:600;">gta5view</span><br/> + <span style=" font-weight:600;">%8</span><br/> <br/> -A project for viewing Grand Theft Auto V Snapmatic<br/> -Pictures and Savegames<br/> +%9<br/> <br/> Project version: %1<br/> -Project build: %4, %5<br/> +Project build: %4<br/> Compiled with Qt %2<br/> Running with Qt %3<br/> <br/> -Copyright &copy; <a href="https://github.com/Syping/">Syping</a> 2016<br/>gta5view is licensed under <a href="https://www.gnu.org/licenses/gpl-3.0.html#content">GNU GPLv3</a> +Copyright &copy; <a href="%5">%6</a> %7<br/>%8 is licensed under <a href="https://www.gnu.org/licenses/gpl-3.0.html#content">GNU GPLv3</a> - + &Close @@ -40,6 +39,18 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping Close Закрыть + + + A project for viewing Grand Theft Auto V Snapmatic<br/> +Pictures and Savegames + + + + + A project for viewing and sync Grand Theft Auto V Snapmatic<br/> +Pictures and Savegames + + ExportDialog @@ -49,61 +60,99 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping - + &JPEG/PNG format - + GTA &Snapmatic format - + Export Format - + Export Size - + Default &Size - + &Desktop Size - + &Custom Size - + Custom Size: - + x - + &Export - + &Close + + ImportDialog + + + Import... + + + + + Settings + + + + + &Keep Aspect Ratio + + + + + &Ignore Aspect Ratio + + + + + &Avatar + + + + + &OK + + + + + &Cancel + + + OptionsDialog @@ -244,56 +293,66 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping - + + Sync + + + + + Sync is not implemented at current time + + + + &OK OK, Cancel, Apply - + &Cancel OK, Cancel, Apply - + System System like PC System - + %1 (%2 if available) System like PC System = %1, System Language like Deutsch = %2 - - + + %1 %1 - + The new Custom Folder will initialize after you restart %1. - + The language change will take effect after you restart %1. - + No Profile No Profile, as default - - - + + + Profile: %1 @@ -330,7 +389,7 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping - + &Export @@ -340,7 +399,7 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping - + Export Экспорт @@ -354,95 +413,117 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping Закрыть - + Export as &JPG picture... - + Export as &GTA Snapmatic... - - + + Key 1 - Avatar Preview Mode +Key 2 - Toggle Overlay +Arrow Keys - Navigate + + + + + Snapmatic Picture Viewer Просмотрщик фотографий Snapmatic - - + + Failed at %1 Ошибка при %1 - - + + Avatar Preview Mode +Press 1 for Default View + + + + + No player Игроков нет - - + + No crew Без группы - + Unknown Location - + Export as JPG picture... - + JPEG picture (*.jpg) Картинка JPEG (*.jpg) - + Portable Network Graphics (*.png) Картинка Portable Network Graphics (*.png) - - - - + + + + Export as JPG picture - - + + Overwrite %1 with current Snapmatic picture? Перезаписать %1 текущей картинкой Snapmatic? - - - - + + + + + + Export as GTA Snapmatic - - + + Failed to overwrite %1 with current Snapmatic picture Не удалось перезаписать %1 картинкой Snapmatic - + + + Failed to export current Snapmatic picture Не удалось экспортировать текущую картинку Snapmatic - - + + Exported Snapmatic to "%1" because of using the .auto extension. + + + + + No valid file is selected Выбранный файл неверен @@ -451,24 +532,32 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping Скопировать картинку - + Export as GTA Snapmatic... - + + GTA V Export (*.g5e) + + + + + GTA V Raw Export (*.auto) + + + + Snapmatic pictures (PGTA*) Картинки Snapmatic (PGTA*) - All files (**) - Все файлы (**) + Все файлы (**) - Failed to copy current Snapmatic picture - Не удалось скопировать текущую картинку Snapmatic + Не удалось скопировать текущую картинку Snapmatic @@ -517,154 +606,169 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping Закрыть профиль - + Loading... Загрузка... - + + Import... - - - - - - - - - - - - + + + + + + + + + + + + Import - - All profile files (SGTA* PGTA*) - Все файлы профиля (SGTA* PGTA*) + Все файлы профиля (SGTA* PGTA*) - - + + Savegames files (SGTA*) Файлы сохранения (SGTA*) - - + + Snapmatic pictures (PGTA*) Картинка Snapmatic (PGTA*) - - + + All files (**) Все файлы (**) - + + + Import file %1 of %2 files + + + + Import failed with... %1 - - + + Failed to read Snapmatic picture Не удалось загрузить картинку Snapmatic - - + + Failed to read Savegame file Не удалось загрузить файл сохранения - + Can't import %1 because of not valid file format Не получилось импортировать %1 из-за неправильного формата файла - - - + + + No valid file is selected Выбранный файл неверен - + Enabled pictures: %1 of %2 - - Failed to import the Snapmatic picture, file not begin with PGTA + + Importable files (*.g5e *.jpg *.png SGTA* PGTA*) - + + All image files (*.jpg *.png) + + + + + Failed to import the Snapmatic picture, file not begin with PGTA or end with .g5e + + + + Failed to import the Snapmatic picture, the picture is already in the game - + Failed to import the Snapmatic picture, can't copy the file into profile - + Failed to import the Savegame, can't copy the file into profile - + Failed to import the Savegame, no Savegame slot is left - - + + JPG pictures and GTA Snapmatic - - + + JPG pictures only - - + + GTA Snapmatic only - - + + No Snapmatic pictures or Savegames files are selected - - - + + + Remove selected - + You really want remove the selected Snapmatic picutres and Savegame files? - + Failed at remove the complete selected Snapmatic pictures and/or Savegame files @@ -685,42 +789,53 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping Не получилось имортировать копию сохранения, потому что не осталось свободных под них слотов - - - - + + + + Export selected - + %1Export Snapmatic pictures%2<br><br>JPG pictures make it possible to open the picture with a Image Viewer<br>GTA Snapmatic make it possible to import the picture into the game<br><br>Export as: - + Export selected... - + Initializing export... - + Export failed with... %1 - - - + + + Export file %1 of %2 files + + + All profile files (*.g5e SGTA* PGTA*) + + + + + + GTA V Export (*.g5e) + + QApplication @@ -739,22 +854,22 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping SavegameDialog - + Savegame Viewer Просмотрщик сохранений - + <span style=" font-weight:600;">Savegame</span><br><br>%1 <span style=" font-weight:600;">Сохранение</span><br><br>%1 - + &Export - + &Close @@ -767,7 +882,7 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping Закрыть - + Failed at %1 Ошибка при %1 @@ -795,6 +910,7 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping + Export Экспорт @@ -809,13 +925,13 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping - - + + Delete savegame Удалить сохранение - + Export Savegame... @@ -825,67 +941,67 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping + - WRONG FORMAT - + AUTOSAVE - %1 %2 - + SAVE %3 - %1 %2 - + UNKNOWN - + Are you sure to delete %1 from your savegames? Вы уверены, что хотите удалить сохранение %1? - + Failed at deleting %1 from your savegames Не удалось удалить сохранение %1 - + &View - + &Remove - - + + &Select - + &Deselect - - + + Select &All - + &Deselect All @@ -895,8 +1011,7 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping Копировать сохранение - - + &Export @@ -955,79 +1070,128 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping SnapmaticEditor - - + + Snapmatic Properties - + Snapmatic Type - - + + Editor - - + + Selfie - + Regular - - + + Mugshot - + Director - + Meme - + + + Snapmatic Title + + + + + + Title: %1 (%2) + + + + + + + Appropriate: %1 + + + + Extras - + Qualify as Avatar automatically at apply - + Qualify as Avatar allows you to use this Snapmatic as a Social Club profile picture - + &Apply - + &Cancel - + + Edit + + + + + Yes + Yes, should work fine + + + + + No + No, could lead to issues + + + + Patching of Snapmatic Properties failed because of I/O Error + + + New Snapmatic title: + + + + + SnapmaticPicture + + + PHOTO - %1 + + SnapmaticWidget @@ -1068,85 +1232,85 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping - - + + Delete picture Удалить картинку - + Are you sure to delete %1 from your Snapmatic pictures? Уверены, что хотите удалить %1 из коллекции картинок Snapmatic? - + Failed at deleting %1 from your Snapmatic pictures Не удалось удалить %1 из колелкции картинок Snapmatic - + Edi&t - + Show &In-game - + Hide &In-game - + &Edit Properties... - + &Export - + Export as &JPG picture... - + Export as &GTA Snapmatic... - + &View - + &Remove - - + + &Select - + &Deselect - - + + Select &All - + &Deselect All @@ -1178,93 +1342,93 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping - + &File - + &Help - + &Edit - + &Profile - + &Exit - + Exit - + Close &Profile - + Ctrl+End - + &Settings - + Ctrl+Del - + &Import files... - + Ctrl+I - - + + Select &GTA V Folder... - + Ctrl+G - + Show In-gam&e - + Shift+E - + Hi&de In-game - + Shift+D @@ -1274,37 +1438,27 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping - - gta5view - %1 - - - - + &Selection visibility - - &About gta5view - - - - + Select &All - + &Deselect All - + &Export selected... - + &Remove selected @@ -1321,7 +1475,7 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping О программе gta5sync - + Ctrl+A Ctrl+A @@ -1330,74 +1484,81 @@ Copyright &copy; <a href="https://github.com/Syping/">Syping Закрыть - + Ctrl+Q Ctrl+Q - + Ctrl+P Ctrl+P - + &Open File... - + Ctrl+O - + Ctrl+S - + Ctrl+E - + Ctrl+D - - + + Select Profile - - - - + + + + Select GTA V Folder... - + + %2 - %1 - + + + &About %1 + + + + Open File... - - - - + + + + Open File - + Can't open %1 because of not valid file format diff --git a/main.cpp b/main.cpp index 76d49b3..eeacd3d 100755 --- a/main.cpp +++ b/main.cpp @@ -432,7 +432,6 @@ int main(int argc, char *argv[]) SnapmaticPicture picture; bool readOk = picture.readingPictureFromFile(arg1); - picDialog.setWindowFlags(picDialog.windowFlags()^Qt::WindowContextHelpButtonHint); picDialog.setWindowIcon(IconLoader::loadingAppIcon()); picDialog.setSnapmaticPicture(&picture, readOk); diff --git a/qjson4/QJsonArray b/qjson4/QJsonArray index 89dbf4e..93afb31 100755 --- a/qjson4/QJsonArray +++ b/qjson4/QJsonArray @@ -1 +1 @@ -#include "QJsonArray.h" +#include "QJsonArray.h" diff --git a/qjson4/QJsonArray.cpp b/qjson4/QJsonArray.cpp index 531941f..f932825 100755 --- a/qjson4/QJsonArray.cpp +++ b/qjson4/QJsonArray.cpp @@ -1,410 +1,410 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "QJsonArray.h" -#include "QJsonValueRef.h" -#include "QJsonValue.h" -#include - -#if QT_VERSION < 0x050000 - -//------------------------------------------------------------------------------ -// Name: QJsonArray -// Desc: default constructor -//------------------------------------------------------------------------------ -QJsonArray::QJsonArray() { - -} - -//------------------------------------------------------------------------------ -// Name: QJsonArray -// Desc: copy constructor -//------------------------------------------------------------------------------ -QJsonArray::QJsonArray(const QJsonArray &other) : values_(other.values_) { - -} - -#if __cplusplus >= 201103L -//------------------------------------------------------------------------------ -// Name: QJsonArray -// Desc: Creates an array initialized from args initialization list. -//------------------------------------------------------------------------------ -QJsonArray::QJsonArray(std::initializer_list args) { - for(const QJsonValue &arg : args) { - values_.append(arg); - } -} -#endif - -//------------------------------------------------------------------------------ -// Name: ~QJsonArray -// Desc: destructor -//------------------------------------------------------------------------------ -QJsonArray::~QJsonArray() { - -} - -//------------------------------------------------------------------------------ -// Name: operator= -// Desc: assignment operator -//------------------------------------------------------------------------------ -QJsonArray &QJsonArray::operator=(const QJsonArray &other) { - QJsonArray(other).swap(*this); - return *this; -} - -//------------------------------------------------------------------------------ -// Name: operator+= -// Desc: -//------------------------------------------------------------------------------ -QJsonArray &QJsonArray::operator+=(const QJsonValue &value) { - values_.append(value); - return *this; -} - -//------------------------------------------------------------------------------ -// Name: operator<< -// Desc: -//------------------------------------------------------------------------------ -QJsonArray &QJsonArray::operator<<(const QJsonValue &value) { - values_.append(value); - return *this; -} - -//------------------------------------------------------------------------------ -// Name: operator+ -// Desc: -//------------------------------------------------------------------------------ -QJsonArray QJsonArray::operator+(const QJsonValue &value) const { - QJsonArray arr(*this); - arr.append(value); - return arr; -} - -//------------------------------------------------------------------------------ -// Name: operator!= -// Desc: returns true if the compared array IS NOT equal to this -//------------------------------------------------------------------------------ -bool QJsonArray::operator!=(const QJsonArray &other) const { - return values_ != other.values_; -} - -//------------------------------------------------------------------------------ -// Name: operator== -// Desc: returns true if the compared array IS equal to this -//------------------------------------------------------------------------------ -bool QJsonArray::operator==(const QJsonArray &other) const { - return values_ == other.values_; -} - -//------------------------------------------------------------------------------ -// Name: begin -// Desc: returns an iterator to the first contained element -//------------------------------------------------------------------------------ -QJsonArray::const_iterator QJsonArray::begin() const { - return values_.begin(); -} - -//------------------------------------------------------------------------------ -// Name: end -// Desc: returns an iterator to one past the last contained element -//------------------------------------------------------------------------------ -QJsonArray::const_iterator QJsonArray::end() const { - return values_.end(); -} - -//------------------------------------------------------------------------------ -// Name: begin -// Desc: returns an iterator to the first contained element -//------------------------------------------------------------------------------ -QJsonArray::iterator QJsonArray::begin() { - return values_.begin(); -} - -//------------------------------------------------------------------------------ -// Name: end -// Desc: returns an iterator to one past the last contained element -//------------------------------------------------------------------------------ -QJsonArray::iterator QJsonArray::end() { - return values_.end(); -} - -//------------------------------------------------------------------------------ -// Name: constBegin -// Desc: returns an iterator to the first contained element -//------------------------------------------------------------------------------ -QJsonArray::const_iterator QJsonArray::constBegin() const { - return begin(); -} - -//------------------------------------------------------------------------------ -// Name: constEnd -// Desc: returns an iterator to one past the last contained element -//------------------------------------------------------------------------------ -QJsonArray::const_iterator QJsonArray::constEnd() const { - return end(); -} - -//------------------------------------------------------------------------------ -// Name: first -// Desc: returns the first element by value -//------------------------------------------------------------------------------ -QJsonValue QJsonArray::first() const { - Q_ASSERT(!empty()); - return values_.first(); -} - -//------------------------------------------------------------------------------ -// Name: last -// Desc: returns the last element by value -//------------------------------------------------------------------------------ -QJsonValue QJsonArray::last() const { - Q_ASSERT(!empty()); - return values_.last(); -} - -//------------------------------------------------------------------------------ -// Name: operator[] -//------------------------------------------------------------------------------ -QJsonValueRef QJsonArray::operator[](int i) { - return QJsonValueRef(this, i); -} - -//------------------------------------------------------------------------------ -// Name: operator[] -//------------------------------------------------------------------------------ -QJsonValue QJsonArray::operator[](int i) const { - return values_[i]; -} - -//------------------------------------------------------------------------------ -// Name: at -//------------------------------------------------------------------------------ -QJsonValue QJsonArray::at(int i) const { - return values_.at(i); -} - -//------------------------------------------------------------------------------ -// Name: size -//------------------------------------------------------------------------------ -int QJsonArray::size() const { - return values_.size(); -} - -//------------------------------------------------------------------------------ -// Name: count -//------------------------------------------------------------------------------ -int QJsonArray::count() const { - return size(); -} - -//------------------------------------------------------------------------------ -// Name: empty -//------------------------------------------------------------------------------ -bool QJsonArray::empty() const { - return values_.empty(); -} - -//------------------------------------------------------------------------------ -// Name: isEmpty -//------------------------------------------------------------------------------ -bool QJsonArray::isEmpty() const { - return empty(); -} - -//------------------------------------------------------------------------------ -// Name: pop_back -//------------------------------------------------------------------------------ -void QJsonArray::pop_back() { - values_.pop_back(); -} - -//------------------------------------------------------------------------------ -// Name: pop_front -//------------------------------------------------------------------------------ -void QJsonArray::pop_front() { - values_.pop_front(); -} - -//------------------------------------------------------------------------------ -// Name: push_back -//------------------------------------------------------------------------------ -void QJsonArray::push_back(const QJsonValue &value) { - values_.push_back(value); -} - -//------------------------------------------------------------------------------ -// Name: push_front -//------------------------------------------------------------------------------ -void QJsonArray::push_front(const QJsonValue &value) { - values_.push_front(value); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonArray::append(const QJsonValue &value) { - values_.append(value); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -bool QJsonArray::contains(const QJsonValue &value) const { - return values_.contains(value); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonArray::iterator QJsonArray::erase(iterator it) { - return values_.erase(it); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonArray::insert(int i, const QJsonValue &value) { - values_.insert(i, value); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonArray::iterator QJsonArray::insert(iterator before, const QJsonValue &value) { - return values_.insert(before, value); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonArray::prepend(const QJsonValue &value) { - values_.prepend(value); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonArray::removeAt(int i) { - values_.removeAt(i); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonArray::removeFirst() { - values_.removeFirst(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonArray::removeLast() { - values_.removeLast(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonArray::replace(int i, const QJsonValue &value) { - values_.replace(i, value); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonValue QJsonArray::takeAt(int i) { - return values_.takeAt(i); -} - -//------------------------------------------------------------------------------ -// Name: toVariantList -//------------------------------------------------------------------------------ -QVariantList QJsonArray::toVariantList() const { - QVariantList a; - Q_FOREACH(const QJsonValue &v, *this) { - a.push_back(v.toVariant()); - } - return a; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonArray QJsonArray::fromStringList(const QStringList &list) { - QJsonArray a; - Q_FOREACH(const QString &s, list) { - a.push_back(QJsonValue(s)); - } - return a; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonArray QJsonArray::fromVariantList(const QVariantList &list) { - QJsonArray a; - Q_FOREACH(const QVariant &v, list) { - a.push_back(QJsonValue::fromVariant(v)); - } - return a; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonRoot *QJsonArray::clone() const { - return new QJsonArray(*this); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -const QJsonObject *QJsonArray::toObject() const { - return 0; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject *QJsonArray::toObject() { - return 0; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonArray *QJsonArray::toArray() { - return this; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -const QJsonArray *QJsonArray::toArray() const { - return this; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonArray::swap(QJsonArray &other) { - qSwap(values_, other.values_); -} - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "QJsonArray.h" +#include "QJsonValueRef.h" +#include "QJsonValue.h" +#include + +#if QT_VERSION < 0x050000 + +//------------------------------------------------------------------------------ +// Name: QJsonArray +// Desc: default constructor +//------------------------------------------------------------------------------ +QJsonArray::QJsonArray() { + +} + +//------------------------------------------------------------------------------ +// Name: QJsonArray +// Desc: copy constructor +//------------------------------------------------------------------------------ +QJsonArray::QJsonArray(const QJsonArray &other) : values_(other.values_) { + +} + +#if __cplusplus >= 201103L +//------------------------------------------------------------------------------ +// Name: QJsonArray +// Desc: Creates an array initialized from args initialization list. +//------------------------------------------------------------------------------ +QJsonArray::QJsonArray(std::initializer_list args) { + for(const QJsonValue &arg : args) { + values_.append(arg); + } +} +#endif + +//------------------------------------------------------------------------------ +// Name: ~QJsonArray +// Desc: destructor +//------------------------------------------------------------------------------ +QJsonArray::~QJsonArray() { + +} + +//------------------------------------------------------------------------------ +// Name: operator= +// Desc: assignment operator +//------------------------------------------------------------------------------ +QJsonArray &QJsonArray::operator=(const QJsonArray &other) { + QJsonArray(other).swap(*this); + return *this; +} + +//------------------------------------------------------------------------------ +// Name: operator+= +// Desc: +//------------------------------------------------------------------------------ +QJsonArray &QJsonArray::operator+=(const QJsonValue &value) { + values_.append(value); + return *this; +} + +//------------------------------------------------------------------------------ +// Name: operator<< +// Desc: +//------------------------------------------------------------------------------ +QJsonArray &QJsonArray::operator<<(const QJsonValue &value) { + values_.append(value); + return *this; +} + +//------------------------------------------------------------------------------ +// Name: operator+ +// Desc: +//------------------------------------------------------------------------------ +QJsonArray QJsonArray::operator+(const QJsonValue &value) const { + QJsonArray arr(*this); + arr.append(value); + return arr; +} + +//------------------------------------------------------------------------------ +// Name: operator!= +// Desc: returns true if the compared array IS NOT equal to this +//------------------------------------------------------------------------------ +bool QJsonArray::operator!=(const QJsonArray &other) const { + return values_ != other.values_; +} + +//------------------------------------------------------------------------------ +// Name: operator== +// Desc: returns true if the compared array IS equal to this +//------------------------------------------------------------------------------ +bool QJsonArray::operator==(const QJsonArray &other) const { + return values_ == other.values_; +} + +//------------------------------------------------------------------------------ +// Name: begin +// Desc: returns an iterator to the first contained element +//------------------------------------------------------------------------------ +QJsonArray::const_iterator QJsonArray::begin() const { + return values_.begin(); +} + +//------------------------------------------------------------------------------ +// Name: end +// Desc: returns an iterator to one past the last contained element +//------------------------------------------------------------------------------ +QJsonArray::const_iterator QJsonArray::end() const { + return values_.end(); +} + +//------------------------------------------------------------------------------ +// Name: begin +// Desc: returns an iterator to the first contained element +//------------------------------------------------------------------------------ +QJsonArray::iterator QJsonArray::begin() { + return values_.begin(); +} + +//------------------------------------------------------------------------------ +// Name: end +// Desc: returns an iterator to one past the last contained element +//------------------------------------------------------------------------------ +QJsonArray::iterator QJsonArray::end() { + return values_.end(); +} + +//------------------------------------------------------------------------------ +// Name: constBegin +// Desc: returns an iterator to the first contained element +//------------------------------------------------------------------------------ +QJsonArray::const_iterator QJsonArray::constBegin() const { + return begin(); +} + +//------------------------------------------------------------------------------ +// Name: constEnd +// Desc: returns an iterator to one past the last contained element +//------------------------------------------------------------------------------ +QJsonArray::const_iterator QJsonArray::constEnd() const { + return end(); +} + +//------------------------------------------------------------------------------ +// Name: first +// Desc: returns the first element by value +//------------------------------------------------------------------------------ +QJsonValue QJsonArray::first() const { + Q_ASSERT(!empty()); + return values_.first(); +} + +//------------------------------------------------------------------------------ +// Name: last +// Desc: returns the last element by value +//------------------------------------------------------------------------------ +QJsonValue QJsonArray::last() const { + Q_ASSERT(!empty()); + return values_.last(); +} + +//------------------------------------------------------------------------------ +// Name: operator[] +//------------------------------------------------------------------------------ +QJsonValueRef QJsonArray::operator[](int i) { + return QJsonValueRef(this, i); +} + +//------------------------------------------------------------------------------ +// Name: operator[] +//------------------------------------------------------------------------------ +QJsonValue QJsonArray::operator[](int i) const { + return values_[i]; +} + +//------------------------------------------------------------------------------ +// Name: at +//------------------------------------------------------------------------------ +QJsonValue QJsonArray::at(int i) const { + return values_.at(i); +} + +//------------------------------------------------------------------------------ +// Name: size +//------------------------------------------------------------------------------ +int QJsonArray::size() const { + return values_.size(); +} + +//------------------------------------------------------------------------------ +// Name: count +//------------------------------------------------------------------------------ +int QJsonArray::count() const { + return size(); +} + +//------------------------------------------------------------------------------ +// Name: empty +//------------------------------------------------------------------------------ +bool QJsonArray::empty() const { + return values_.empty(); +} + +//------------------------------------------------------------------------------ +// Name: isEmpty +//------------------------------------------------------------------------------ +bool QJsonArray::isEmpty() const { + return empty(); +} + +//------------------------------------------------------------------------------ +// Name: pop_back +//------------------------------------------------------------------------------ +void QJsonArray::pop_back() { + values_.pop_back(); +} + +//------------------------------------------------------------------------------ +// Name: pop_front +//------------------------------------------------------------------------------ +void QJsonArray::pop_front() { + values_.pop_front(); +} + +//------------------------------------------------------------------------------ +// Name: push_back +//------------------------------------------------------------------------------ +void QJsonArray::push_back(const QJsonValue &value) { + values_.push_back(value); +} + +//------------------------------------------------------------------------------ +// Name: push_front +//------------------------------------------------------------------------------ +void QJsonArray::push_front(const QJsonValue &value) { + values_.push_front(value); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonArray::append(const QJsonValue &value) { + values_.append(value); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +bool QJsonArray::contains(const QJsonValue &value) const { + return values_.contains(value); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonArray::iterator QJsonArray::erase(iterator it) { + return values_.erase(it); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonArray::insert(int i, const QJsonValue &value) { + values_.insert(i, value); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonArray::iterator QJsonArray::insert(iterator before, const QJsonValue &value) { + return values_.insert(before, value); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonArray::prepend(const QJsonValue &value) { + values_.prepend(value); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonArray::removeAt(int i) { + values_.removeAt(i); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonArray::removeFirst() { + values_.removeFirst(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonArray::removeLast() { + values_.removeLast(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonArray::replace(int i, const QJsonValue &value) { + values_.replace(i, value); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonValue QJsonArray::takeAt(int i) { + return values_.takeAt(i); +} + +//------------------------------------------------------------------------------ +// Name: toVariantList +//------------------------------------------------------------------------------ +QVariantList QJsonArray::toVariantList() const { + QVariantList a; + Q_FOREACH(const QJsonValue &v, *this) { + a.push_back(v.toVariant()); + } + return a; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonArray QJsonArray::fromStringList(const QStringList &list) { + QJsonArray a; + Q_FOREACH(const QString &s, list) { + a.push_back(QJsonValue(s)); + } + return a; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonArray QJsonArray::fromVariantList(const QVariantList &list) { + QJsonArray a; + Q_FOREACH(const QVariant &v, list) { + a.push_back(QJsonValue::fromVariant(v)); + } + return a; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonRoot *QJsonArray::clone() const { + return new QJsonArray(*this); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +const QJsonObject *QJsonArray::toObject() const { + return 0; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject *QJsonArray::toObject() { + return 0; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonArray *QJsonArray::toArray() { + return this; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +const QJsonArray *QJsonArray::toArray() const { + return this; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonArray::swap(QJsonArray &other) { + qSwap(values_, other.values_); +} + +#endif diff --git a/qjson4/QJsonArray.h b/qjson4/QJsonArray.h index 94aab1b..2e443b4 100755 --- a/qjson4/QJsonArray.h +++ b/qjson4/QJsonArray.h @@ -1,139 +1,139 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef QJSON_ARRAY_H_ -#define QJSON_ARRAY_H_ - -#include - -#if QT_VERSION >= 0x050000 -#include -#else - -#include "QJsonRoot.h" -#include -#include - -class QJsonValue; -class QJsonValueRef; - -class QJsonArray : public QJsonRoot { - friend class QJsonDocument; - friend class QJsonValue; - friend class QJsonValueRef; - friend class QJsonParser; -public: - // TODO(eteran): manually implement the array, for now we use QList - // but the real thing has a custom implementation - // I guess for the purposes of less interdependancies? - // maybe so it's easier to forward declare the iterators? - - typedef QList::const_iterator const_iterator; - typedef QList::iterator iterator; - typedef const_iterator ConstIterator; - typedef iterator Iterator; - typedef QList::const_pointer const_pointer; - typedef QList::const_reference const_reference; - typedef QList::difference_type difference_type; - typedef QList::pointer pointer; - typedef QList::reference reference; - typedef QList::size_type size_type; - typedef QList::value_type value_type; - -public: - QJsonArray(); - QJsonArray(const QJsonArray &other); -#if __cplusplus >= 201103L - QJsonArray(std::initializer_list args); -#endif - ~QJsonArray(); - -public: - QJsonArray &operator=(const QJsonArray &other); - -public: - bool operator!=(const QJsonArray &other) const; - bool operator==(const QJsonArray &other) const; - QJsonArray operator+(const QJsonValue &value) const; - QJsonArray &operator+=(const QJsonValue &value); - QJsonArray &operator<<(const QJsonValue &value); - -public: - const_iterator begin() const; - const_iterator end() const; - iterator begin(); - iterator end(); - const_iterator constBegin() const; - const_iterator constEnd() const; - -public: - QJsonValueRef operator[](int i); - QJsonValue operator[](int i) const; - QJsonValue at(int i) const; - QJsonValue first() const; - QJsonValue last() const; - -public: - int size() const; - int count() const; - bool empty() const; - bool isEmpty() const; - -public: - void pop_back(); - void pop_front(); - void push_back(const QJsonValue &value); - void push_front(const QJsonValue &value); - -public: - void append(const QJsonValue &value); - bool contains(const QJsonValue &value) const; - iterator erase(iterator it); - void insert(int i, const QJsonValue &value); - iterator insert(iterator before, const QJsonValue &value); - void prepend(const QJsonValue &value); - void removeAt(int i); - void removeFirst(); - void removeLast(); - void replace(int i, const QJsonValue &value); - QJsonValue takeAt(int i); - -public: - QVariantList toVariantList() const; - -public: - static QJsonArray fromStringList(const QStringList &list); - static QJsonArray fromVariantList(const QVariantList &list); - -private: - virtual QJsonRoot *clone() const; - virtual QJsonArray *toArray(); - virtual QJsonObject *toObject(); - virtual const QJsonArray *toArray() const; - virtual const QJsonObject *toObject() const; - -private: - void swap(QJsonArray &other); - -private: - QList values_; -}; - -#endif - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef QJSON_ARRAY_H_ +#define QJSON_ARRAY_H_ + +#include + +#if QT_VERSION >= 0x050000 +#include +#else + +#include "QJsonRoot.h" +#include +#include + +class QJsonValue; +class QJsonValueRef; + +class QJsonArray : public QJsonRoot { + friend class QJsonDocument; + friend class QJsonValue; + friend class QJsonValueRef; + friend class QJsonParser; +public: + // TODO(eteran): manually implement the array, for now we use QList + // but the real thing has a custom implementation + // I guess for the purposes of less interdependancies? + // maybe so it's easier to forward declare the iterators? + + typedef QList::const_iterator const_iterator; + typedef QList::iterator iterator; + typedef const_iterator ConstIterator; + typedef iterator Iterator; + typedef QList::const_pointer const_pointer; + typedef QList::const_reference const_reference; + typedef QList::difference_type difference_type; + typedef QList::pointer pointer; + typedef QList::reference reference; + typedef QList::size_type size_type; + typedef QList::value_type value_type; + +public: + QJsonArray(); + QJsonArray(const QJsonArray &other); +#if __cplusplus >= 201103L + QJsonArray(std::initializer_list args); +#endif + ~QJsonArray(); + +public: + QJsonArray &operator=(const QJsonArray &other); + +public: + bool operator!=(const QJsonArray &other) const; + bool operator==(const QJsonArray &other) const; + QJsonArray operator+(const QJsonValue &value) const; + QJsonArray &operator+=(const QJsonValue &value); + QJsonArray &operator<<(const QJsonValue &value); + +public: + const_iterator begin() const; + const_iterator end() const; + iterator begin(); + iterator end(); + const_iterator constBegin() const; + const_iterator constEnd() const; + +public: + QJsonValueRef operator[](int i); + QJsonValue operator[](int i) const; + QJsonValue at(int i) const; + QJsonValue first() const; + QJsonValue last() const; + +public: + int size() const; + int count() const; + bool empty() const; + bool isEmpty() const; + +public: + void pop_back(); + void pop_front(); + void push_back(const QJsonValue &value); + void push_front(const QJsonValue &value); + +public: + void append(const QJsonValue &value); + bool contains(const QJsonValue &value) const; + iterator erase(iterator it); + void insert(int i, const QJsonValue &value); + iterator insert(iterator before, const QJsonValue &value); + void prepend(const QJsonValue &value); + void removeAt(int i); + void removeFirst(); + void removeLast(); + void replace(int i, const QJsonValue &value); + QJsonValue takeAt(int i); + +public: + QVariantList toVariantList() const; + +public: + static QJsonArray fromStringList(const QStringList &list); + static QJsonArray fromVariantList(const QVariantList &list); + +private: + virtual QJsonRoot *clone() const; + virtual QJsonArray *toArray(); + virtual QJsonObject *toObject(); + virtual const QJsonArray *toArray() const; + virtual const QJsonObject *toObject() const; + +private: + void swap(QJsonArray &other); + +private: + QList values_; +}; + +#endif + +#endif diff --git a/qjson4/QJsonDocument b/qjson4/QJsonDocument index f652bf4..dabae9b 100755 --- a/qjson4/QJsonDocument +++ b/qjson4/QJsonDocument @@ -1 +1 @@ -#include "QJsonDocument.h" +#include "QJsonDocument.h" diff --git a/qjson4/QJsonDocument.cpp b/qjson4/QJsonDocument.cpp index 59adf32..712a96d 100755 --- a/qjson4/QJsonDocument.cpp +++ b/qjson4/QJsonDocument.cpp @@ -1,417 +1,417 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "QJsonDocument.h" -#include "QJsonObject.h" -#include "QJsonArray.h" -#include "QJsonParser.h" - -#include -#include -#include -#include -#include - -#if QT_VERSION < 0x050000 - -//------------------------------------------------------------------------------ -// Name: QJsonDocument -//------------------------------------------------------------------------------ -QJsonDocument::QJsonDocument() : root_(0) { -} - -//------------------------------------------------------------------------------ -// Name: QJsonDocument -//------------------------------------------------------------------------------ -QJsonDocument::QJsonDocument(const QJsonObject &object) : root_(0) { - setObject(object); -} - -//------------------------------------------------------------------------------ -// Name: QJsonDocument -//------------------------------------------------------------------------------ -QJsonDocument::QJsonDocument(const QJsonArray &array) : root_(0) { - setArray(array); -} - -//------------------------------------------------------------------------------ -// Name: QJsonDocument -//------------------------------------------------------------------------------ -QJsonDocument::QJsonDocument(const QJsonDocument &other) : root_(0) { - if(other.root_) { - root_ = other.root_->clone(); - } -} - -//------------------------------------------------------------------------------ -// Name: ~QJsonDocument -//------------------------------------------------------------------------------ -QJsonDocument::~QJsonDocument() { - delete root_; -} - -//------------------------------------------------------------------------------ -// Name: operator= -//------------------------------------------------------------------------------ -QJsonDocument &QJsonDocument::operator=(const QJsonDocument &other) { - QJsonDocument(other).swap(*this); - return *this; -} - -//------------------------------------------------------------------------------ -// Name: operator!= -//------------------------------------------------------------------------------ -bool QJsonDocument::operator!=(const QJsonDocument &other) const { - return !(*this == other); -} - -//------------------------------------------------------------------------------ -// Name: operator== -//------------------------------------------------------------------------------ -bool QJsonDocument::operator==(const QJsonDocument &other) const { - - if(isArray() && other.isArray()) { - return array() == other.array(); - } - - if(isObject() && other.isObject()) { - return object() == other.object(); - } - - if(isEmpty() && other.isEmpty()) { - return true; - } - - if(isNull() && other.isNull()) { - return true; - } - - return false; -} - -//------------------------------------------------------------------------------ -// Name: isArray -//------------------------------------------------------------------------------ -bool QJsonDocument::isArray() const { - return root_ && root_->toArray(); -} - -//------------------------------------------------------------------------------ -// Name: isEmpty -//------------------------------------------------------------------------------ -bool QJsonDocument::isEmpty() const { - - // TODO(eteran): figure out the rules here that Qt5 uses - // it *looks* like they define empty as being NULL - // which is obviously different than this - - return !root_; -} - -//------------------------------------------------------------------------------ -// Name: isNull -//------------------------------------------------------------------------------ -bool QJsonDocument::isNull() const { - return !root_; -} - -//------------------------------------------------------------------------------ -// Name: isObject -//------------------------------------------------------------------------------ -bool QJsonDocument::isObject() const { - return root_ && root_->toObject(); -} - -//------------------------------------------------------------------------------ -// Name: setArray -//------------------------------------------------------------------------------ -void QJsonDocument::setArray(const QJsonArray &array) { - setRoot(array); -} - -//------------------------------------------------------------------------------ -// Name: setObject -//------------------------------------------------------------------------------ -void QJsonDocument::setObject(const QJsonObject &object) { - setRoot(object); -} - -//------------------------------------------------------------------------------ -// Name: setRoot -//------------------------------------------------------------------------------ -void QJsonDocument::setRoot(const QJsonRoot &root) { - delete root_; - root_ = root.clone(); -} - -//------------------------------------------------------------------------------ -// Name: toBinaryData -//------------------------------------------------------------------------------ -QByteArray QJsonDocument::toBinaryData() const { - QByteArray r; - // TODO(eteran): implement this - return r; -} - -//------------------------------------------------------------------------------ -// Name: escapeString -//------------------------------------------------------------------------------ -QString QJsonDocument::escapeString(const QString &s) const { - - QString r; - - Q_FOREACH(QChar ch, s) { - switch(ch.toLatin1()) { - case '\"': r.append("\\\""); break; - case '\\': r.append("\\\\"); break; - #if 0 - case '/': r.append("\\/"); break; - #endif - case '\b': r.append("\\b"); break; - case '\f': r.append("\\f"); break; - case '\n': r.append("\\n"); break; - case '\r': r.append("\\r"); break; - case '\t': r.append("\\t"); break; - default: - r += ch; - break; - } - } - - return r; -} - -//------------------------------------------------------------------------------ -// Name: toJson -//------------------------------------------------------------------------------ -QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const { - - QString b; - QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text); - - switch(v.type()) { - case QJsonValue::Null: - ss << "null"; - break; - case QJsonValue::Bool: - ss << (v.toBool() ? "true" : "false"); - break; - case QJsonValue::Double: - { - double d = v.toDouble (); - if (qIsFinite(d)) { - // +2 to format to ensure the expected precision - ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15 - } else { - ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4) - } - } - break; - case QJsonValue::String: - ss << '"' << escapeString(v.toString()) << '"'; - break; - case QJsonValue::Array: - { - const QJsonArray a = v.toArray(); - ss << "["; - if(!a.empty()) { - QJsonArray::const_iterator it = a.begin(); - QJsonArray::const_iterator e = a.end(); - - ss << toJson(*it++, format); - - for(;it != e; ++it) { - ss << ','; - ss << toJson(*it, format); - } - } - ss << "]"; - } - break; - case QJsonValue::Object: - { - const QJsonObject o = v.toObject(); - ss << "{"; - if(!o.empty()) { - QJsonObject::const_iterator it = o.begin(); - QJsonObject::const_iterator e = o.end(); - - ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format); - ++it; - for(;it != e; ++it) { - ss << ','; - ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format); - } - } - ss << "}"; - } - break; - case QJsonValue::Undefined: - Q_ASSERT(0); - break; - } - - return b; -} - -//------------------------------------------------------------------------------ -// Name: toJson -//------------------------------------------------------------------------------ -QByteArray QJsonDocument::toJson(JsonFormat format) const { - - Q_UNUSED(format); - - if(isArray()) { - QString s = toJson(array(), format); - return s.toUtf8(); - } - - if(isObject()) { - QString s = toJson(object(), format); - return s.toUtf8(); - } - - return QByteArray(); -} - -//------------------------------------------------------------------------------ -// Name: toVariant -//------------------------------------------------------------------------------ -QVariant QJsonDocument::toVariant() const { - - if(!isEmpty()) { - if(QJsonObject *const object = root_->toObject()) { - return object->toVariantMap(); - } - - if(QJsonArray *const array = root_->toArray()) { - return array->toVariantList(); - } - } - - return QVariant(); -} - -//------------------------------------------------------------------------------ -// Name: array -//------------------------------------------------------------------------------ -QJsonArray QJsonDocument::array() const { - - if(!isEmpty()) { - if(QJsonArray *const array = root_->toArray()) { - return *array; - } - } - - return QJsonArray(); -} - -//------------------------------------------------------------------------------ -// Name: object -//------------------------------------------------------------------------------ -QJsonObject QJsonDocument::object() const { - - if(!isEmpty()) { - if(QJsonObject *const object = root_->toObject()) { - return *object; - } - } - - return QJsonObject(); -} - -//------------------------------------------------------------------------------ -// Name: rawData -//------------------------------------------------------------------------------ -const char *QJsonDocument::rawData(int *size) const { - Q_UNUSED(size); - // TODO(eteran): implement this - return 0; -} - -//------------------------------------------------------------------------------ -// Name: fromBinaryData -//------------------------------------------------------------------------------ -QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation) { - Q_UNUSED(data); - Q_UNUSED(validation); - - QJsonDocument doc; - // TODO(eteran): implement this - return doc; -} - -//------------------------------------------------------------------------------ -// Name: fromJson -//------------------------------------------------------------------------------ -QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) { - QJsonDocument doc; - - const char *const begin = json.constData(); - const char *const end = begin + json.size(); - - QJsonParser parser(begin, end); - - doc.root_ = parser.parse(); - - if(error) { - *error = parser.state(); - } - - return doc; -} - -//------------------------------------------------------------------------------ -// Name: fromRawData -//------------------------------------------------------------------------------ -QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation) { - - // data has to be aligned to a 4 byte boundary. - Q_ASSERT(!(reinterpret_cast(data) % 3)); - - return fromBinaryData(QByteArray::fromRawData(data, size), validation); -} - -//------------------------------------------------------------------------------ -// Name: fromVariant -//------------------------------------------------------------------------------ -QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) { - - QJsonDocument doc; - - if (variant.type() == QVariant::Map) { - doc.setObject(QJsonObject::fromVariantMap(variant.toMap())); - } else if (variant.type() == QVariant::Hash) { - doc.setObject(QJsonObject::fromVariantHash(variant.toHash())); - } else if (variant.type() == QVariant::List) { - doc.setArray(QJsonArray::fromVariantList(variant.toList())); - } else if (variant.type() == QVariant::StringList) { - doc.setArray(QJsonArray::fromStringList(variant.toStringList())); - } - - return doc; -} - -//------------------------------------------------------------------------------ -// Name: swap -//------------------------------------------------------------------------------ -void QJsonDocument::swap(QJsonDocument &other) { - qSwap(root_, other.root_); -} - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "QJsonDocument.h" +#include "QJsonObject.h" +#include "QJsonArray.h" +#include "QJsonParser.h" + +#include +#include +#include +#include +#include + +#if QT_VERSION < 0x050000 + +//------------------------------------------------------------------------------ +// Name: QJsonDocument +//------------------------------------------------------------------------------ +QJsonDocument::QJsonDocument() : root_(0) { +} + +//------------------------------------------------------------------------------ +// Name: QJsonDocument +//------------------------------------------------------------------------------ +QJsonDocument::QJsonDocument(const QJsonObject &object) : root_(0) { + setObject(object); +} + +//------------------------------------------------------------------------------ +// Name: QJsonDocument +//------------------------------------------------------------------------------ +QJsonDocument::QJsonDocument(const QJsonArray &array) : root_(0) { + setArray(array); +} + +//------------------------------------------------------------------------------ +// Name: QJsonDocument +//------------------------------------------------------------------------------ +QJsonDocument::QJsonDocument(const QJsonDocument &other) : root_(0) { + if(other.root_) { + root_ = other.root_->clone(); + } +} + +//------------------------------------------------------------------------------ +// Name: ~QJsonDocument +//------------------------------------------------------------------------------ +QJsonDocument::~QJsonDocument() { + delete root_; +} + +//------------------------------------------------------------------------------ +// Name: operator= +//------------------------------------------------------------------------------ +QJsonDocument &QJsonDocument::operator=(const QJsonDocument &other) { + QJsonDocument(other).swap(*this); + return *this; +} + +//------------------------------------------------------------------------------ +// Name: operator!= +//------------------------------------------------------------------------------ +bool QJsonDocument::operator!=(const QJsonDocument &other) const { + return !(*this == other); +} + +//------------------------------------------------------------------------------ +// Name: operator== +//------------------------------------------------------------------------------ +bool QJsonDocument::operator==(const QJsonDocument &other) const { + + if(isArray() && other.isArray()) { + return array() == other.array(); + } + + if(isObject() && other.isObject()) { + return object() == other.object(); + } + + if(isEmpty() && other.isEmpty()) { + return true; + } + + if(isNull() && other.isNull()) { + return true; + } + + return false; +} + +//------------------------------------------------------------------------------ +// Name: isArray +//------------------------------------------------------------------------------ +bool QJsonDocument::isArray() const { + return root_ && root_->toArray(); +} + +//------------------------------------------------------------------------------ +// Name: isEmpty +//------------------------------------------------------------------------------ +bool QJsonDocument::isEmpty() const { + + // TODO(eteran): figure out the rules here that Qt5 uses + // it *looks* like they define empty as being NULL + // which is obviously different than this + + return !root_; +} + +//------------------------------------------------------------------------------ +// Name: isNull +//------------------------------------------------------------------------------ +bool QJsonDocument::isNull() const { + return !root_; +} + +//------------------------------------------------------------------------------ +// Name: isObject +//------------------------------------------------------------------------------ +bool QJsonDocument::isObject() const { + return root_ && root_->toObject(); +} + +//------------------------------------------------------------------------------ +// Name: setArray +//------------------------------------------------------------------------------ +void QJsonDocument::setArray(const QJsonArray &array) { + setRoot(array); +} + +//------------------------------------------------------------------------------ +// Name: setObject +//------------------------------------------------------------------------------ +void QJsonDocument::setObject(const QJsonObject &object) { + setRoot(object); +} + +//------------------------------------------------------------------------------ +// Name: setRoot +//------------------------------------------------------------------------------ +void QJsonDocument::setRoot(const QJsonRoot &root) { + delete root_; + root_ = root.clone(); +} + +//------------------------------------------------------------------------------ +// Name: toBinaryData +//------------------------------------------------------------------------------ +QByteArray QJsonDocument::toBinaryData() const { + QByteArray r; + // TODO(eteran): implement this + return r; +} + +//------------------------------------------------------------------------------ +// Name: escapeString +//------------------------------------------------------------------------------ +QString QJsonDocument::escapeString(const QString &s) const { + + QString r; + + Q_FOREACH(QChar ch, s) { + switch(ch.toLatin1()) { + case '\"': r.append("\\\""); break; + case '\\': r.append("\\\\"); break; + #if 0 + case '/': r.append("\\/"); break; + #endif + case '\b': r.append("\\b"); break; + case '\f': r.append("\\f"); break; + case '\n': r.append("\\n"); break; + case '\r': r.append("\\r"); break; + case '\t': r.append("\\t"); break; + default: + r += ch; + break; + } + } + + return r; +} + +//------------------------------------------------------------------------------ +// Name: toJson +//------------------------------------------------------------------------------ +QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const { + + QString b; + QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text); + + switch(v.type()) { + case QJsonValue::Null: + ss << "null"; + break; + case QJsonValue::Bool: + ss << (v.toBool() ? "true" : "false"); + break; + case QJsonValue::Double: + { + double d = v.toDouble (); + if (qIsFinite(d)) { + // +2 to format to ensure the expected precision + ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15 + } else { + ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4) + } + } + break; + case QJsonValue::String: + ss << '"' << escapeString(v.toString()) << '"'; + break; + case QJsonValue::Array: + { + const QJsonArray a = v.toArray(); + ss << "["; + if(!a.empty()) { + QJsonArray::const_iterator it = a.begin(); + QJsonArray::const_iterator e = a.end(); + + ss << toJson(*it++, format); + + for(;it != e; ++it) { + ss << ','; + ss << toJson(*it, format); + } + } + ss << "]"; + } + break; + case QJsonValue::Object: + { + const QJsonObject o = v.toObject(); + ss << "{"; + if(!o.empty()) { + QJsonObject::const_iterator it = o.begin(); + QJsonObject::const_iterator e = o.end(); + + ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format); + ++it; + for(;it != e; ++it) { + ss << ','; + ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format); + } + } + ss << "}"; + } + break; + case QJsonValue::Undefined: + Q_ASSERT(0); + break; + } + + return b; +} + +//------------------------------------------------------------------------------ +// Name: toJson +//------------------------------------------------------------------------------ +QByteArray QJsonDocument::toJson(JsonFormat format) const { + + Q_UNUSED(format); + + if(isArray()) { + QString s = toJson(array(), format); + return s.toUtf8(); + } + + if(isObject()) { + QString s = toJson(object(), format); + return s.toUtf8(); + } + + return QByteArray(); +} + +//------------------------------------------------------------------------------ +// Name: toVariant +//------------------------------------------------------------------------------ +QVariant QJsonDocument::toVariant() const { + + if(!isEmpty()) { + if(QJsonObject *const object = root_->toObject()) { + return object->toVariantMap(); + } + + if(QJsonArray *const array = root_->toArray()) { + return array->toVariantList(); + } + } + + return QVariant(); +} + +//------------------------------------------------------------------------------ +// Name: array +//------------------------------------------------------------------------------ +QJsonArray QJsonDocument::array() const { + + if(!isEmpty()) { + if(QJsonArray *const array = root_->toArray()) { + return *array; + } + } + + return QJsonArray(); +} + +//------------------------------------------------------------------------------ +// Name: object +//------------------------------------------------------------------------------ +QJsonObject QJsonDocument::object() const { + + if(!isEmpty()) { + if(QJsonObject *const object = root_->toObject()) { + return *object; + } + } + + return QJsonObject(); +} + +//------------------------------------------------------------------------------ +// Name: rawData +//------------------------------------------------------------------------------ +const char *QJsonDocument::rawData(int *size) const { + Q_UNUSED(size); + // TODO(eteran): implement this + return 0; +} + +//------------------------------------------------------------------------------ +// Name: fromBinaryData +//------------------------------------------------------------------------------ +QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation) { + Q_UNUSED(data); + Q_UNUSED(validation); + + QJsonDocument doc; + // TODO(eteran): implement this + return doc; +} + +//------------------------------------------------------------------------------ +// Name: fromJson +//------------------------------------------------------------------------------ +QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) { + QJsonDocument doc; + + const char *const begin = json.constData(); + const char *const end = begin + json.size(); + + QJsonParser parser(begin, end); + + doc.root_ = parser.parse(); + + if(error) { + *error = parser.state(); + } + + return doc; +} + +//------------------------------------------------------------------------------ +// Name: fromRawData +//------------------------------------------------------------------------------ +QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation) { + + // data has to be aligned to a 4 byte boundary. + Q_ASSERT(!(reinterpret_cast(data) % 3)); + + return fromBinaryData(QByteArray::fromRawData(data, size), validation); +} + +//------------------------------------------------------------------------------ +// Name: fromVariant +//------------------------------------------------------------------------------ +QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) { + + QJsonDocument doc; + + if (variant.type() == QVariant::Map) { + doc.setObject(QJsonObject::fromVariantMap(variant.toMap())); + } else if (variant.type() == QVariant::Hash) { + doc.setObject(QJsonObject::fromVariantHash(variant.toHash())); + } else if (variant.type() == QVariant::List) { + doc.setArray(QJsonArray::fromVariantList(variant.toList())); + } else if (variant.type() == QVariant::StringList) { + doc.setArray(QJsonArray::fromStringList(variant.toStringList())); + } + + return doc; +} + +//------------------------------------------------------------------------------ +// Name: swap +//------------------------------------------------------------------------------ +void QJsonDocument::swap(QJsonDocument &other) { + qSwap(root_, other.root_); +} + +#endif diff --git a/qjson4/QJsonDocument.h b/qjson4/QJsonDocument.h index 12e8fc7..32ae72f 100755 --- a/qjson4/QJsonDocument.h +++ b/qjson4/QJsonDocument.h @@ -1,103 +1,103 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef QJSON_DOCUMENT_H_ -#define QJSON_DOCUMENT_H_ - -#include - -#if QT_VERSION >= 0x050000 -#include -#else - -class QVariant; -class QByteArray; -class QTextStream; -class QJsonObject; -class QJsonValue; -class QJsonArray; -class QJsonParseError; -class QJsonRoot; - -class QJsonDocument { -public: - enum DataValidation { - Validate = 0, - BypassValidation = 1 - }; - - enum JsonFormat { - Indented, - Compact - }; - -public: - QJsonDocument(); - QJsonDocument(const QJsonObject &object); - QJsonDocument(const QJsonArray &array); - QJsonDocument(const QJsonDocument &other); - ~QJsonDocument(); - -public: - QJsonDocument &operator=(const QJsonDocument &other); - -public: - bool operator!=(const QJsonDocument &other) const; - bool operator==(const QJsonDocument &other) const; - -public: - bool isArray() const; - bool isEmpty() const; - bool isNull() const; - bool isObject() const; - -public: - QByteArray toBinaryData() const; - QByteArray toJson(JsonFormat format = Indented) const; - QVariant toVariant() const; - -public: - QJsonArray array() const; - QJsonObject object() const; - const char *rawData(int *size) const; - -public: - void setArray(const QJsonArray &array); - void setObject(const QJsonObject &object); - -public: - static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate); - static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0); - static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate); - static QJsonDocument fromVariant(const QVariant &variant); - -private: - void setRoot(const QJsonRoot &root); - QString toJson(const QJsonValue &v, JsonFormat format) const; - QString escapeString(const QString &s) const; - -private: - void swap(QJsonDocument &other); - -private: - QJsonRoot *root_; -}; - -#endif - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef QJSON_DOCUMENT_H_ +#define QJSON_DOCUMENT_H_ + +#include + +#if QT_VERSION >= 0x050000 +#include +#else + +class QVariant; +class QByteArray; +class QTextStream; +class QJsonObject; +class QJsonValue; +class QJsonArray; +class QJsonParseError; +class QJsonRoot; + +class QJsonDocument { +public: + enum DataValidation { + Validate = 0, + BypassValidation = 1 + }; + + enum JsonFormat { + Indented, + Compact + }; + +public: + QJsonDocument(); + QJsonDocument(const QJsonObject &object); + QJsonDocument(const QJsonArray &array); + QJsonDocument(const QJsonDocument &other); + ~QJsonDocument(); + +public: + QJsonDocument &operator=(const QJsonDocument &other); + +public: + bool operator!=(const QJsonDocument &other) const; + bool operator==(const QJsonDocument &other) const; + +public: + bool isArray() const; + bool isEmpty() const; + bool isNull() const; + bool isObject() const; + +public: + QByteArray toBinaryData() const; + QByteArray toJson(JsonFormat format = Indented) const; + QVariant toVariant() const; + +public: + QJsonArray array() const; + QJsonObject object() const; + const char *rawData(int *size) const; + +public: + void setArray(const QJsonArray &array); + void setObject(const QJsonObject &object); + +public: + static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate); + static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0); + static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate); + static QJsonDocument fromVariant(const QVariant &variant); + +private: + void setRoot(const QJsonRoot &root); + QString toJson(const QJsonValue &v, JsonFormat format) const; + QString escapeString(const QString &s) const; + +private: + void swap(QJsonDocument &other); + +private: + QJsonRoot *root_; +}; + +#endif + +#endif diff --git a/qjson4/QJsonObject b/qjson4/QJsonObject index fb2126e..2009be3 100755 --- a/qjson4/QJsonObject +++ b/qjson4/QJsonObject @@ -1 +1 @@ -#include "QJsonObject.h" +#include "QJsonObject.h" diff --git a/qjson4/QJsonObject.cpp b/qjson4/QJsonObject.cpp index 55f8cf1..4a9e15a 100755 --- a/qjson4/QJsonObject.cpp +++ b/qjson4/QJsonObject.cpp @@ -1,322 +1,322 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "QJsonObject.h" - -#if QT_VERSION < 0x050000 - -//------------------------------------------------------------------------------ -// Name: QJsonObject -//------------------------------------------------------------------------------ -QJsonObject::QJsonObject() { -} - -//------------------------------------------------------------------------------ -// Name: QJsonObject -//------------------------------------------------------------------------------ -QJsonObject::QJsonObject(const QJsonObject &other) : values_(other.values_) { -} - -#if __cplusplus >= 201103L -//------------------------------------------------------------------------------ -// Name: QJsonObject -//------------------------------------------------------------------------------ -QJsonObject::QJsonObject(std::initializer_list > args) { - for(const QPair &arg : args) { - values_.insert(arg.first, arg.second); - - } -} -#endif - -//------------------------------------------------------------------------------ -// Name: ~QJsonObject -//------------------------------------------------------------------------------ -QJsonObject::~QJsonObject() { -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject &QJsonObject::operator=(const QJsonObject &other) { - QJsonObject(other).swap(*this); - return *this; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::iterator QJsonObject::begin() { - return values_.begin(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::const_iterator QJsonObject::begin() const { - return values_.begin(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::iterator QJsonObject::end() { - return values_.end(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::const_iterator QJsonObject::end() const { - return values_.end(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::const_iterator QJsonObject::constBegin() const { - return begin(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::const_iterator QJsonObject::constEnd() const { - return end(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -int QJsonObject::count() const { - return size(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -int QJsonObject::length() const { - return size(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -int QJsonObject::size() const { - return values_.size(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -bool QJsonObject::empty() const { - return values_.empty(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -bool QJsonObject::isEmpty() const { - return empty(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const { - return values_.find(key); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -bool QJsonObject::contains(const QString &key) const { - return values_.contains(key); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::iterator QJsonObject::find(const QString &key) { - return values_.find(key); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::const_iterator QJsonObject::find(const QString &key) const { - return values_.find(key); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::iterator QJsonObject::erase(iterator it) { - return values_.erase(it); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &value) { - return values_.insert(key, value); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QStringList QJsonObject::keys() const { - return values_.keys(); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -void QJsonObject::remove(const QString &key) { - values_.remove(key); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonValue QJsonObject::take(const QString &key) { - return values_.take(key); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonValue QJsonObject::value(const QString &key) const { - return values_.value(key); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -bool QJsonObject::operator!=(const QJsonObject &other) const { - return values_ != other.values_; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -bool QJsonObject::operator==(const QJsonObject &other) const { - return values_ != other.values_; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonValue QJsonObject::operator[](const QString &key) const { - return values_[key]; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonValueRef QJsonObject::operator[](const QString &key) { - return QJsonValueRef(this, key); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QVariantMap QJsonObject::toVariantMap() const { - QVariantMap a; - for(const_iterator it = begin(); it != end(); ++it) { - a.insert(it.key(), it.value().toVariant()); - } - return a; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QVariantHash QJsonObject::toVariantHash() const { - QVariantHash a; - for(const_iterator it = begin(); it != end(); ++it) { - a.insert(it.key(), it.value().toVariant()); - } - return a; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map) { - QJsonObject o; - for(QVariantMap::const_iterator it = map.begin(); it != map.end(); ++it) { - o.insert(it.key(), QJsonValue::fromVariant(it.value())); - } - return o; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject QJsonObject::fromVariantHash(const QVariantHash &hash) { - QJsonObject o; - for(QVariantHash::const_iterator it = hash.begin(); it != hash.end(); ++it) { - o.insert(it.key(), QJsonValue::fromVariant(it.value())); - } - return o; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonRoot *QJsonObject::clone() const { - return new QJsonObject(*this); -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -const QJsonObject *QJsonObject::toObject() const { - return this; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonObject *QJsonObject::toObject() { - return this; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -QJsonArray *QJsonObject::toArray() { - return 0; -} - -//------------------------------------------------------------------------------ -// Name: -//------------------------------------------------------------------------------ -const QJsonArray *QJsonObject::toArray() const { - return 0; -} - -//------------------------------------------------------------------------------ -// Name: swap -//------------------------------------------------------------------------------ -void QJsonObject::swap(QJsonObject &other) { - qSwap(values_, other.values_); -} - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "QJsonObject.h" + +#if QT_VERSION < 0x050000 + +//------------------------------------------------------------------------------ +// Name: QJsonObject +//------------------------------------------------------------------------------ +QJsonObject::QJsonObject() { +} + +//------------------------------------------------------------------------------ +// Name: QJsonObject +//------------------------------------------------------------------------------ +QJsonObject::QJsonObject(const QJsonObject &other) : values_(other.values_) { +} + +#if __cplusplus >= 201103L +//------------------------------------------------------------------------------ +// Name: QJsonObject +//------------------------------------------------------------------------------ +QJsonObject::QJsonObject(std::initializer_list > args) { + for(const QPair &arg : args) { + values_.insert(arg.first, arg.second); + + } +} +#endif + +//------------------------------------------------------------------------------ +// Name: ~QJsonObject +//------------------------------------------------------------------------------ +QJsonObject::~QJsonObject() { +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject &QJsonObject::operator=(const QJsonObject &other) { + QJsonObject(other).swap(*this); + return *this; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::iterator QJsonObject::begin() { + return values_.begin(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::const_iterator QJsonObject::begin() const { + return values_.begin(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::iterator QJsonObject::end() { + return values_.end(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::const_iterator QJsonObject::end() const { + return values_.end(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::const_iterator QJsonObject::constBegin() const { + return begin(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::const_iterator QJsonObject::constEnd() const { + return end(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +int QJsonObject::count() const { + return size(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +int QJsonObject::length() const { + return size(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +int QJsonObject::size() const { + return values_.size(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +bool QJsonObject::empty() const { + return values_.empty(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +bool QJsonObject::isEmpty() const { + return empty(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const { + return values_.find(key); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +bool QJsonObject::contains(const QString &key) const { + return values_.contains(key); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::iterator QJsonObject::find(const QString &key) { + return values_.find(key); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::const_iterator QJsonObject::find(const QString &key) const { + return values_.find(key); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::iterator QJsonObject::erase(iterator it) { + return values_.erase(it); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &value) { + return values_.insert(key, value); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QStringList QJsonObject::keys() const { + return values_.keys(); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +void QJsonObject::remove(const QString &key) { + values_.remove(key); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonValue QJsonObject::take(const QString &key) { + return values_.take(key); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonValue QJsonObject::value(const QString &key) const { + return values_.value(key); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +bool QJsonObject::operator!=(const QJsonObject &other) const { + return values_ != other.values_; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +bool QJsonObject::operator==(const QJsonObject &other) const { + return values_ != other.values_; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonValue QJsonObject::operator[](const QString &key) const { + return values_[key]; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonValueRef QJsonObject::operator[](const QString &key) { + return QJsonValueRef(this, key); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QVariantMap QJsonObject::toVariantMap() const { + QVariantMap a; + for(const_iterator it = begin(); it != end(); ++it) { + a.insert(it.key(), it.value().toVariant()); + } + return a; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QVariantHash QJsonObject::toVariantHash() const { + QVariantHash a; + for(const_iterator it = begin(); it != end(); ++it) { + a.insert(it.key(), it.value().toVariant()); + } + return a; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map) { + QJsonObject o; + for(QVariantMap::const_iterator it = map.begin(); it != map.end(); ++it) { + o.insert(it.key(), QJsonValue::fromVariant(it.value())); + } + return o; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject QJsonObject::fromVariantHash(const QVariantHash &hash) { + QJsonObject o; + for(QVariantHash::const_iterator it = hash.begin(); it != hash.end(); ++it) { + o.insert(it.key(), QJsonValue::fromVariant(it.value())); + } + return o; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonRoot *QJsonObject::clone() const { + return new QJsonObject(*this); +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +const QJsonObject *QJsonObject::toObject() const { + return this; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonObject *QJsonObject::toObject() { + return this; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +QJsonArray *QJsonObject::toArray() { + return 0; +} + +//------------------------------------------------------------------------------ +// Name: +//------------------------------------------------------------------------------ +const QJsonArray *QJsonObject::toArray() const { + return 0; +} + +//------------------------------------------------------------------------------ +// Name: swap +//------------------------------------------------------------------------------ +void QJsonObject::swap(QJsonObject &other) { + qSwap(values_, other.values_); +} + +#endif diff --git a/qjson4/QJsonObject.h b/qjson4/QJsonObject.h index ad657bc..50a6ee5 100755 --- a/qjson4/QJsonObject.h +++ b/qjson4/QJsonObject.h @@ -1,121 +1,121 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef QJSON_OBJECT_H_ -#define QJSON_OBJECT_H_ - -#include - -#if QT_VERSION >= 0x050000 -#include -#else - -#include "QJsonRoot.h" -#include "QJsonValueRef.h" -#include "QJsonValue.h" -#include -#include -#include -#include - -class QJsonObject : public QJsonRoot { - friend class QJsonDocument; - friend class QJsonValue; - friend class QJsonValueRef; - friend class QJsonParser; -public: - // TODO(eteran): manually implement the map, for now we use QMap - // but the real thing has a custom implementation - // I guess for the purposes of less interdependancies? - // maybe so it's easier to forward declare the iterators? - - typedef QMap::const_iterator const_iterator; - typedef QMap::iterator iterator; - typedef const_iterator ConstIterator; - typedef iterator Iterator; - typedef QMap::key_type key_type; - typedef QMap::mapped_type mapped_type; - typedef QMap::size_type size_type; - -public: - QJsonObject(); -#if __cplusplus >= 201103L - QJsonObject(std::initializer_list > args); -#endif - QJsonObject(const QJsonObject &other); - ~QJsonObject(); - QJsonObject &operator=(const QJsonObject &other); - -public: - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - const_iterator constBegin() const; - const_iterator constEnd() const; - -public: - int count() const; - int length() const; - int size() const; - bool empty() const; - bool isEmpty() const; - -public: - const_iterator constFind(const QString &key) const; - bool contains(const QString &key) const; - iterator find(const QString &key); - const_iterator find(const QString &key) const; - -public: - iterator erase(iterator it); - iterator insert(const QString &key, const QJsonValue &value); - QStringList keys() const; - void remove(const QString &key); - QJsonValue take(const QString &key); - QJsonValue value(const QString &key) const; - bool operator!=(const QJsonObject &other) const; - bool operator==(const QJsonObject &other) const; - QJsonValue operator[](const QString &key) const; - QJsonValueRef operator[](const QString &key); - -public: - QVariantMap toVariantMap() const; - QVariantHash toVariantHash() const; - -public: - static QJsonObject fromVariantMap(const QVariantMap &map); - static QJsonObject fromVariantHash(const QVariantHash &hash); - -private: - virtual QJsonRoot *clone() const; - virtual QJsonArray *toArray(); - virtual QJsonObject *toObject(); - virtual const QJsonArray *toArray() const; - virtual const QJsonObject *toObject() const; - -private: - void swap(QJsonObject &other); - -private: - QMap values_; -}; - -#endif - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef QJSON_OBJECT_H_ +#define QJSON_OBJECT_H_ + +#include + +#if QT_VERSION >= 0x050000 +#include +#else + +#include "QJsonRoot.h" +#include "QJsonValueRef.h" +#include "QJsonValue.h" +#include +#include +#include +#include + +class QJsonObject : public QJsonRoot { + friend class QJsonDocument; + friend class QJsonValue; + friend class QJsonValueRef; + friend class QJsonParser; +public: + // TODO(eteran): manually implement the map, for now we use QMap + // but the real thing has a custom implementation + // I guess for the purposes of less interdependancies? + // maybe so it's easier to forward declare the iterators? + + typedef QMap::const_iterator const_iterator; + typedef QMap::iterator iterator; + typedef const_iterator ConstIterator; + typedef iterator Iterator; + typedef QMap::key_type key_type; + typedef QMap::mapped_type mapped_type; + typedef QMap::size_type size_type; + +public: + QJsonObject(); +#if __cplusplus >= 201103L + QJsonObject(std::initializer_list > args); +#endif + QJsonObject(const QJsonObject &other); + ~QJsonObject(); + QJsonObject &operator=(const QJsonObject &other); + +public: + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + const_iterator constBegin() const; + const_iterator constEnd() const; + +public: + int count() const; + int length() const; + int size() const; + bool empty() const; + bool isEmpty() const; + +public: + const_iterator constFind(const QString &key) const; + bool contains(const QString &key) const; + iterator find(const QString &key); + const_iterator find(const QString &key) const; + +public: + iterator erase(iterator it); + iterator insert(const QString &key, const QJsonValue &value); + QStringList keys() const; + void remove(const QString &key); + QJsonValue take(const QString &key); + QJsonValue value(const QString &key) const; + bool operator!=(const QJsonObject &other) const; + bool operator==(const QJsonObject &other) const; + QJsonValue operator[](const QString &key) const; + QJsonValueRef operator[](const QString &key); + +public: + QVariantMap toVariantMap() const; + QVariantHash toVariantHash() const; + +public: + static QJsonObject fromVariantMap(const QVariantMap &map); + static QJsonObject fromVariantHash(const QVariantHash &hash); + +private: + virtual QJsonRoot *clone() const; + virtual QJsonArray *toArray(); + virtual QJsonObject *toObject(); + virtual const QJsonArray *toArray() const; + virtual const QJsonObject *toObject() const; + +private: + void swap(QJsonObject &other); + +private: + QMap values_; +}; + +#endif + +#endif diff --git a/qjson4/QJsonParseError b/qjson4/QJsonParseError index 7d30db8..de177e3 100755 --- a/qjson4/QJsonParseError +++ b/qjson4/QJsonParseError @@ -1 +1 @@ -#include "QJsonParseError.h" +#include "QJsonParseError.h" diff --git a/qjson4/QJsonParseError.cpp b/qjson4/QJsonParseError.cpp index 6bcfd98..fa19f15 100755 --- a/qjson4/QJsonParseError.cpp +++ b/qjson4/QJsonParseError.cpp @@ -1,64 +1,64 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "QJsonParseError.h" - -#if QT_VERSION < 0x050000 - -//------------------------------------------------------------------------------ -// Name: errorString -// Desc: The QJsonParseError class is used to report errors during JSON parsing. -//------------------------------------------------------------------------------ -QString QJsonParseError::errorString() const { - switch(error) { - case NoError: - return "No error occurred"; - case UnterminatedObject: - return "unterminated object"; - case MissingNameSeparator: - return "missing name separator"; - case UnterminatedArray: - return "unterminated array"; - case MissingValueSeparator: - return "missing value separator"; - case IllegalValue: - return "illegal value"; - case TerminationByNumber: - return "invalid termination by number"; - case IllegalNumber: - return "illegal number"; - case IllegalEscapeSequence: - return "illegal escape sequence"; - case IllegalUTF8String: - return "invalid UTF8 string"; - case UnterminatedString: - return "unterminated string"; - case MissingObject: - return "object is missing after a comma"; - case DeepNesting: - return "too deeply nested document"; - case DocumentTooLarge: - return "too large document"; - case GarbageAtEnd: - return "garbage at the end of the document"; - } - - return QString(); -} - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "QJsonParseError.h" + +#if QT_VERSION < 0x050000 + +//------------------------------------------------------------------------------ +// Name: errorString +// Desc: The QJsonParseError class is used to report errors during JSON parsing. +//------------------------------------------------------------------------------ +QString QJsonParseError::errorString() const { + switch(error) { + case NoError: + return "No error occurred"; + case UnterminatedObject: + return "unterminated object"; + case MissingNameSeparator: + return "missing name separator"; + case UnterminatedArray: + return "unterminated array"; + case MissingValueSeparator: + return "missing value separator"; + case IllegalValue: + return "illegal value"; + case TerminationByNumber: + return "invalid termination by number"; + case IllegalNumber: + return "illegal number"; + case IllegalEscapeSequence: + return "illegal escape sequence"; + case IllegalUTF8String: + return "invalid UTF8 string"; + case UnterminatedString: + return "unterminated string"; + case MissingObject: + return "object is missing after a comma"; + case DeepNesting: + return "too deeply nested document"; + case DocumentTooLarge: + return "too large document"; + case GarbageAtEnd: + return "garbage at the end of the document"; + } + + return QString(); +} + +#endif diff --git a/qjson4/QJsonParseError.h b/qjson4/QJsonParseError.h index b87d7aa..d2eda8b 100755 --- a/qjson4/QJsonParseError.h +++ b/qjson4/QJsonParseError.h @@ -1,60 +1,60 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef QJSON_PARSE_ERROR_H_ -#define QJSON_PARSE_ERROR_H_ - -#include - -#if QT_VERSION >= 0x050000 -#include -#else - -#include - -class QJsonParseError { -public: - enum ParseError { - NoError = 0, - UnterminatedObject = 1, - MissingNameSeparator = 2, - UnterminatedArray = 3, - MissingValueSeparator = 4, - IllegalValue = 5, - TerminationByNumber = 6, - IllegalNumber = 7, - IllegalEscapeSequence = 8, - IllegalUTF8String = 9, - UnterminatedString = 10, - MissingObject = 11, - DeepNesting = 12, - DocumentTooLarge = 13, - GarbageAtEnd = 14 - }; - -public: - QString errorString() const; - -public: - ParseError error; - int offset; -}; - -#endif - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef QJSON_PARSE_ERROR_H_ +#define QJSON_PARSE_ERROR_H_ + +#include + +#if QT_VERSION >= 0x050000 +#include +#else + +#include + +class QJsonParseError { +public: + enum ParseError { + NoError = 0, + UnterminatedObject = 1, + MissingNameSeparator = 2, + UnterminatedArray = 3, + MissingValueSeparator = 4, + IllegalValue = 5, + TerminationByNumber = 6, + IllegalNumber = 7, + IllegalEscapeSequence = 8, + IllegalUTF8String = 9, + UnterminatedString = 10, + MissingObject = 11, + DeepNesting = 12, + DocumentTooLarge = 13, + GarbageAtEnd = 14 + }; + +public: + QString errorString() const; + +public: + ParseError error; + int offset; +}; + +#endif + +#endif diff --git a/qjson4/QJsonParser.cpp b/qjson4/QJsonParser.cpp index 9b084f7..08c3c62 100755 --- a/qjson4/QJsonParser.cpp +++ b/qjson4/QJsonParser.cpp @@ -1,455 +1,455 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "QJsonParser.h" -#include "QJsonArray.h" -#include "QJsonObject.h" -#include "QJsonValue.h" - - -#if QT_VERSION < 0x050000 - -#include -#include -#include - -namespace { - -unsigned int to_hex(int ch) { - - static const int hexval[256] = { - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 - }; - - if(static_cast(ch) < 256) { - return hexval[static_cast(ch)]; - } else { - return 0; - } -} - -} - -//------------------------------------------------------------------------------ -// Name: QJsonParser -//------------------------------------------------------------------------------ -QJsonParser::QJsonParser(const char *begin, const char *end) : begin_(begin), end_(end), p_(begin) { - state_.error = QJsonParseError::NoError; - state_.offset = 0; -} - -//------------------------------------------------------------------------------ -// Name: parse -//------------------------------------------------------------------------------ -QJsonRoot *QJsonParser::parse() { - if(begin_ == end_) { - return 0; - } - - QJsonRoot *ret = 0; - - try { - const char ch = peek(); - switch(ch) { - case ArrayBegin: - ret = getArray(); - break; - case ObjectBegin: - ret = getObject(); - break; - default: - state_.error = QJsonParseError::IllegalValue; - state_.offset = p_ - begin_; - break; - } - } catch(const QJsonParseError &e) { - state_ = e; - } - - if(ret) { - // eat up trailing white space... - while(p_ != end_ && std::isspace(*p_)) { - ++p_; - } - - //detect trailing garbage - if(p_ != end_) { - state_.error = QJsonParseError::GarbageAtEnd; - state_.offset = p_ - begin_; - } - } - - return ret; -} - -//------------------------------------------------------------------------------ -// Name: peek -//------------------------------------------------------------------------------ -char QJsonParser::peek() { - // first eat up some whitespace - while(p_ != end_ && std::isspace(*p_)) { - ++p_; - } - - return *p_; -} - -//------------------------------------------------------------------------------ -// Name: getValue -//------------------------------------------------------------------------------ -QJsonValue QJsonParser::getValue() { - - switch(peek()) { - case ObjectBegin: - { - QScopedPointer obj(getObject()); - return QJsonValue(*obj); - } - case ArrayBegin: - { - QScopedPointer arr(getArray()); - return QJsonValue(*arr); - } - case Quote: - return QJsonValue(getString()); - case 't': - return getTrue(); - case 'f': - return getFalse(); - case 'n': - return getNull(); - default: - return getNumber(); - } - - throwError(QJsonParseError::MissingObject); - return QJsonValue(); -} - -//------------------------------------------------------------------------------ -// Name: getObject -//------------------------------------------------------------------------------ -QJsonObject *QJsonParser::getObject() { - - QScopedPointer obj(new QJsonObject); - - char tok = peek(); - if(tok != ObjectBegin) { - throwError(QJsonParseError::IllegalValue); - } - - ++p_; - - // handle empty object - tok = peek(); - if(peek() == ObjectEnd) { - ++p_; - } else { - - do { - QPair p = getPair(); - obj->values_.insert(p.first, p.second); - - tok = peek(); - ++p_; - - } while(tok == ValueSeparator); - } - - if(tok != ObjectEnd) { - throwError(QJsonParseError::UnterminatedObject); - } - - return obj.take(); -} - -//------------------------------------------------------------------------------ -// Name: getArray -//------------------------------------------------------------------------------ -QJsonArray *QJsonParser::getArray() { - - QScopedPointer arr(new QJsonArray); - - char tok = peek(); - - if(tok != ArrayBegin) { - throwError(QJsonParseError::IllegalValue); - } - - ++p_; - - // handle empty object - tok = peek(); - if(tok == ArrayEnd) { - ++p_; - } else { - do { - arr->values_.push_back(getValue()); - - tok = peek(); - ++p_; - - } while(tok == ValueSeparator); - } - - if(tok != ArrayEnd) { - throwError(QJsonParseError::MissingValueSeparator); - } - - return arr.take(); -} - -//------------------------------------------------------------------------------ -// Name: getPair -//------------------------------------------------------------------------------ -QPair QJsonParser::getPair() { - - QString key = getString(); - - if(peek() != NameSeparator) { - throwError(QJsonParseError::MissingNameSeparator); - } - ++p_; - - return qMakePair(key, getValue()); -} - -//------------------------------------------------------------------------------ -// Name: getString -//------------------------------------------------------------------------------ -QString QJsonParser::getString() { - - if(peek() != Quote) { - throwError(QJsonParseError::IllegalUTF8String); - } - ++p_; - - QByteArray s; - - while(p_ != end_ && *p_ != Quote && *p_ != '\n') { - if(*p_ == '\\') { - ++p_; - if(p_ != end_) { - switch(*p_) { - case '"': s.append('"'); break; - case '\\': s.append('\\'); break; - case '/': s.append('/'); break; - case 'b': s.append('\b'); break; - case 'f': s.append('\f'); break; - case 'n': s.append('\n'); break; - case 'r': s.append('\r'); break; - case 't': s.append('\t'); break; - case 'u': - { - - QString hexChar; - - // convert \uXXXX escape sequences to UTF-8 - char hex[4]; - if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[0] = *++p_; - if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[1] = *++p_; - if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[2] = *++p_; - if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[3] = *++p_; - - if(!std::isxdigit(hex[0])) throwError(QJsonParseError::IllegalUTF8String); - if(!std::isxdigit(hex[1])) throwError(QJsonParseError::IllegalUTF8String); - if(!std::isxdigit(hex[2])) throwError(QJsonParseError::IllegalUTF8String); - if(!std::isxdigit(hex[3])) throwError(QJsonParseError::IllegalUTF8String); - - quint16 w1 = 0; - quint16 w2 = 0; - - w1 |= (to_hex(hex[0]) << 12); - w1 |= (to_hex(hex[1]) << 8); - w1 |= (to_hex(hex[2]) << 4); - w1 |= (to_hex(hex[3])); - - hexChar.append(QChar(w1)); - - if((w1 & 0xfc00) == 0xdc00) { - throwError(QJsonParseError::IllegalUTF8String); - } - - if((w1 & 0xfc00) == 0xd800) { - // part of a surrogate pair - if(p_ == end_ || *++p_ != '\\') { throwError(QJsonParseError::IllegalEscapeSequence); } - if(p_ == end_ || *++p_ != 'u') { throwError(QJsonParseError::IllegalEscapeSequence); } - - // convert \uXXXX escape sequences to UTF-8 - if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[0] = *++p_; - if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[1] = *++p_; - if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[2] = *++p_; - if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[3] = *++p_; - - if(!std::isxdigit(hex[0])) throwError(QJsonParseError::IllegalUTF8String); - if(!std::isxdigit(hex[1])) throwError(QJsonParseError::IllegalUTF8String); - if(!std::isxdigit(hex[2])) throwError(QJsonParseError::IllegalUTF8String); - if(!std::isxdigit(hex[3])) throwError(QJsonParseError::IllegalUTF8String); - - w2 |= (to_hex(hex[0]) << 12); - w2 |= (to_hex(hex[1]) << 8); - w2 |= (to_hex(hex[2]) << 4); - w2 |= (to_hex(hex[3])); - - hexChar.append(QChar(w2)); - } - - s.append(hexChar.toUtf8()); - } - break; - - default: - s.append('\\'); - break; - } - } - } else { - s.append(*p_); - } - ++p_; - } - - if(*p_ != Quote || p_ == end_) { - throwError(QJsonParseError::UnterminatedString); - } - - ++p_; - - return QString::fromUtf8(s, s.size()); -} - -//------------------------------------------------------------------------------ -// Name: getNull -//------------------------------------------------------------------------------ -QJsonValue QJsonParser::getNull() { - if(p_ == end_ || *p_++ != 'n') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'u') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); } - - return QJsonValue(); -} - -//------------------------------------------------------------------------------ -// Name: getTrue -//------------------------------------------------------------------------------ -QJsonValue QJsonParser::getTrue() { - if(p_ == end_ || *p_++ != 't') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'r') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'u') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'e') { throwError(QJsonParseError::IllegalValue); } - - return QJsonValue(true); -} - -//------------------------------------------------------------------------------ -// Name: getFalse -//------------------------------------------------------------------------------ -QJsonValue QJsonParser::getFalse() { - if(p_ == end_ || *p_++ != 'f') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'a') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 's') { throwError(QJsonParseError::IllegalValue); } - if(p_ == end_ || *p_++ != 'e') { throwError(QJsonParseError::IllegalValue); } - - return QJsonValue(false); -} - -//------------------------------------------------------------------------------ -// Name: getNumber -//------------------------------------------------------------------------------ -QJsonValue QJsonParser::getNumber() { - // JSON numbers fit the regex: -?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)? - - const char *const first = p_; - - // -? - if(p_ != end_ && *p_ == '-') { - ++p_; - } - - // (0|[1-9][0-9]*) - if(p_ != end_) { - if(*p_ >= '1' && *p_ <= '9') { - while(p_ != end_ && std::isdigit(*p_)) { - ++p_; - } - } else if(*p_ == '0') { - ++p_; - } else { - throwError(QJsonParseError::IllegalNumber); - } - } - - // (\.[0-9]+)? - if(p_ != end_ && *p_ == '.') { - ++p_; - if(!std::isdigit(*p_)) { - throwError(QJsonParseError::IllegalNumber); - } - - while(p_ != end_ && std::isdigit(*p_)) { - ++p_; - } - } - - // ([eE][+-]?[0-9]+)? - if(p_ != end_ && (*p_ == 'e' || *p_ == 'E')) { - ++p_; - if(p_ != end_ && (*p_ == '+' || *p_ == '-')) { - ++p_; - } - if(!std::isdigit(*p_)) { - throwError(QJsonParseError::IllegalNumber); - } - while(p_ != end_ && std::isdigit(*p_)) { - ++p_; - } - } - - if(p_ == end_) { - throwError(QJsonParseError::TerminationByNumber); - } - - return QJsonValue(QByteArray::fromRawData(first, p_ - first).toDouble()); -} - -//------------------------------------------------------------------------------ -// Name: state -//------------------------------------------------------------------------------ -QJsonParseError QJsonParser::state() const { - return state_; -} - -//------------------------------------------------------------------------------ -// Name: throwError -//------------------------------------------------------------------------------ -void QJsonParser::throwError(QJsonParseError::ParseError e) { - QJsonParseError err; - err.error = e; - err.offset = p_ - begin_; - throw err; -} - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "QJsonParser.h" +#include "QJsonArray.h" +#include "QJsonObject.h" +#include "QJsonValue.h" + + +#if QT_VERSION < 0x050000 + +#include +#include +#include + +namespace { + +unsigned int to_hex(int ch) { + + static const int hexval[256] = { + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 + }; + + if(static_cast(ch) < 256) { + return hexval[static_cast(ch)]; + } else { + return 0; + } +} + +} + +//------------------------------------------------------------------------------ +// Name: QJsonParser +//------------------------------------------------------------------------------ +QJsonParser::QJsonParser(const char *begin, const char *end) : begin_(begin), end_(end), p_(begin) { + state_.error = QJsonParseError::NoError; + state_.offset = 0; +} + +//------------------------------------------------------------------------------ +// Name: parse +//------------------------------------------------------------------------------ +QJsonRoot *QJsonParser::parse() { + if(begin_ == end_) { + return 0; + } + + QJsonRoot *ret = 0; + + try { + const char ch = peek(); + switch(ch) { + case ArrayBegin: + ret = getArray(); + break; + case ObjectBegin: + ret = getObject(); + break; + default: + state_.error = QJsonParseError::IllegalValue; + state_.offset = p_ - begin_; + break; + } + } catch(const QJsonParseError &e) { + state_ = e; + } + + if(ret) { + // eat up trailing white space... + while(p_ != end_ && std::isspace(*p_)) { + ++p_; + } + + //detect trailing garbage + if(p_ != end_) { + state_.error = QJsonParseError::GarbageAtEnd; + state_.offset = p_ - begin_; + } + } + + return ret; +} + +//------------------------------------------------------------------------------ +// Name: peek +//------------------------------------------------------------------------------ +char QJsonParser::peek() { + // first eat up some whitespace + while(p_ != end_ && std::isspace(*p_)) { + ++p_; + } + + return *p_; +} + +//------------------------------------------------------------------------------ +// Name: getValue +//------------------------------------------------------------------------------ +QJsonValue QJsonParser::getValue() { + + switch(peek()) { + case ObjectBegin: + { + QScopedPointer obj(getObject()); + return QJsonValue(*obj); + } + case ArrayBegin: + { + QScopedPointer arr(getArray()); + return QJsonValue(*arr); + } + case Quote: + return QJsonValue(getString()); + case 't': + return getTrue(); + case 'f': + return getFalse(); + case 'n': + return getNull(); + default: + return getNumber(); + } + + throwError(QJsonParseError::MissingObject); + return QJsonValue(); +} + +//------------------------------------------------------------------------------ +// Name: getObject +//------------------------------------------------------------------------------ +QJsonObject *QJsonParser::getObject() { + + QScopedPointer obj(new QJsonObject); + + char tok = peek(); + if(tok != ObjectBegin) { + throwError(QJsonParseError::IllegalValue); + } + + ++p_; + + // handle empty object + tok = peek(); + if(peek() == ObjectEnd) { + ++p_; + } else { + + do { + QPair p = getPair(); + obj->values_.insert(p.first, p.second); + + tok = peek(); + ++p_; + + } while(tok == ValueSeparator); + } + + if(tok != ObjectEnd) { + throwError(QJsonParseError::UnterminatedObject); + } + + return obj.take(); +} + +//------------------------------------------------------------------------------ +// Name: getArray +//------------------------------------------------------------------------------ +QJsonArray *QJsonParser::getArray() { + + QScopedPointer arr(new QJsonArray); + + char tok = peek(); + + if(tok != ArrayBegin) { + throwError(QJsonParseError::IllegalValue); + } + + ++p_; + + // handle empty object + tok = peek(); + if(tok == ArrayEnd) { + ++p_; + } else { + do { + arr->values_.push_back(getValue()); + + tok = peek(); + ++p_; + + } while(tok == ValueSeparator); + } + + if(tok != ArrayEnd) { + throwError(QJsonParseError::MissingValueSeparator); + } + + return arr.take(); +} + +//------------------------------------------------------------------------------ +// Name: getPair +//------------------------------------------------------------------------------ +QPair QJsonParser::getPair() { + + QString key = getString(); + + if(peek() != NameSeparator) { + throwError(QJsonParseError::MissingNameSeparator); + } + ++p_; + + return qMakePair(key, getValue()); +} + +//------------------------------------------------------------------------------ +// Name: getString +//------------------------------------------------------------------------------ +QString QJsonParser::getString() { + + if(peek() != Quote) { + throwError(QJsonParseError::IllegalUTF8String); + } + ++p_; + + QByteArray s; + + while(p_ != end_ && *p_ != Quote && *p_ != '\n') { + if(*p_ == '\\') { + ++p_; + if(p_ != end_) { + switch(*p_) { + case '"': s.append('"'); break; + case '\\': s.append('\\'); break; + case '/': s.append('/'); break; + case 'b': s.append('\b'); break; + case 'f': s.append('\f'); break; + case 'n': s.append('\n'); break; + case 'r': s.append('\r'); break; + case 't': s.append('\t'); break; + case 'u': + { + + QString hexChar; + + // convert \uXXXX escape sequences to UTF-8 + char hex[4]; + if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[0] = *++p_; + if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[1] = *++p_; + if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[2] = *++p_; + if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[3] = *++p_; + + if(!std::isxdigit(hex[0])) throwError(QJsonParseError::IllegalUTF8String); + if(!std::isxdigit(hex[1])) throwError(QJsonParseError::IllegalUTF8String); + if(!std::isxdigit(hex[2])) throwError(QJsonParseError::IllegalUTF8String); + if(!std::isxdigit(hex[3])) throwError(QJsonParseError::IllegalUTF8String); + + quint16 w1 = 0; + quint16 w2 = 0; + + w1 |= (to_hex(hex[0]) << 12); + w1 |= (to_hex(hex[1]) << 8); + w1 |= (to_hex(hex[2]) << 4); + w1 |= (to_hex(hex[3])); + + hexChar.append(QChar(w1)); + + if((w1 & 0xfc00) == 0xdc00) { + throwError(QJsonParseError::IllegalUTF8String); + } + + if((w1 & 0xfc00) == 0xd800) { + // part of a surrogate pair + if(p_ == end_ || *++p_ != '\\') { throwError(QJsonParseError::IllegalEscapeSequence); } + if(p_ == end_ || *++p_ != 'u') { throwError(QJsonParseError::IllegalEscapeSequence); } + + // convert \uXXXX escape sequences to UTF-8 + if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[0] = *++p_; + if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[1] = *++p_; + if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[2] = *++p_; + if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[3] = *++p_; + + if(!std::isxdigit(hex[0])) throwError(QJsonParseError::IllegalUTF8String); + if(!std::isxdigit(hex[1])) throwError(QJsonParseError::IllegalUTF8String); + if(!std::isxdigit(hex[2])) throwError(QJsonParseError::IllegalUTF8String); + if(!std::isxdigit(hex[3])) throwError(QJsonParseError::IllegalUTF8String); + + w2 |= (to_hex(hex[0]) << 12); + w2 |= (to_hex(hex[1]) << 8); + w2 |= (to_hex(hex[2]) << 4); + w2 |= (to_hex(hex[3])); + + hexChar.append(QChar(w2)); + } + + s.append(hexChar.toUtf8()); + } + break; + + default: + s.append('\\'); + break; + } + } + } else { + s.append(*p_); + } + ++p_; + } + + if(*p_ != Quote || p_ == end_) { + throwError(QJsonParseError::UnterminatedString); + } + + ++p_; + + return QString::fromUtf8(s, s.size()); +} + +//------------------------------------------------------------------------------ +// Name: getNull +//------------------------------------------------------------------------------ +QJsonValue QJsonParser::getNull() { + if(p_ == end_ || *p_++ != 'n') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'u') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); } + + return QJsonValue(); +} + +//------------------------------------------------------------------------------ +// Name: getTrue +//------------------------------------------------------------------------------ +QJsonValue QJsonParser::getTrue() { + if(p_ == end_ || *p_++ != 't') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'r') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'u') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'e') { throwError(QJsonParseError::IllegalValue); } + + return QJsonValue(true); +} + +//------------------------------------------------------------------------------ +// Name: getFalse +//------------------------------------------------------------------------------ +QJsonValue QJsonParser::getFalse() { + if(p_ == end_ || *p_++ != 'f') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'a') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 's') { throwError(QJsonParseError::IllegalValue); } + if(p_ == end_ || *p_++ != 'e') { throwError(QJsonParseError::IllegalValue); } + + return QJsonValue(false); +} + +//------------------------------------------------------------------------------ +// Name: getNumber +//------------------------------------------------------------------------------ +QJsonValue QJsonParser::getNumber() { + // JSON numbers fit the regex: -?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)? + + const char *const first = p_; + + // -? + if(p_ != end_ && *p_ == '-') { + ++p_; + } + + // (0|[1-9][0-9]*) + if(p_ != end_) { + if(*p_ >= '1' && *p_ <= '9') { + while(p_ != end_ && std::isdigit(*p_)) { + ++p_; + } + } else if(*p_ == '0') { + ++p_; + } else { + throwError(QJsonParseError::IllegalNumber); + } + } + + // (\.[0-9]+)? + if(p_ != end_ && *p_ == '.') { + ++p_; + if(!std::isdigit(*p_)) { + throwError(QJsonParseError::IllegalNumber); + } + + while(p_ != end_ && std::isdigit(*p_)) { + ++p_; + } + } + + // ([eE][+-]?[0-9]+)? + if(p_ != end_ && (*p_ == 'e' || *p_ == 'E')) { + ++p_; + if(p_ != end_ && (*p_ == '+' || *p_ == '-')) { + ++p_; + } + if(!std::isdigit(*p_)) { + throwError(QJsonParseError::IllegalNumber); + } + while(p_ != end_ && std::isdigit(*p_)) { + ++p_; + } + } + + if(p_ == end_) { + throwError(QJsonParseError::TerminationByNumber); + } + + return QJsonValue(QByteArray::fromRawData(first, p_ - first).toDouble()); +} + +//------------------------------------------------------------------------------ +// Name: state +//------------------------------------------------------------------------------ +QJsonParseError QJsonParser::state() const { + return state_; +} + +//------------------------------------------------------------------------------ +// Name: throwError +//------------------------------------------------------------------------------ +void QJsonParser::throwError(QJsonParseError::ParseError e) { + QJsonParseError err; + err.error = e; + err.offset = p_ - begin_; + throw err; +} + +#endif diff --git a/qjson4/QJsonParser.h b/qjson4/QJsonParser.h index d54a0d9..0686838 100755 --- a/qjson4/QJsonParser.h +++ b/qjson4/QJsonParser.h @@ -1,81 +1,81 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -// NOTE: this is not part of the "public" Qt API, so using this class directly -// is not recomended - -#ifndef QJSON_PARSER_H_ -#define QJSON_PARSER_H_ - -#include - -#if QT_VERSION < 0x050000 - -#include "QJsonParseError.h" -#include -class QJsonRoot; -class QJsonObject; -class QJsonArray; -class QJsonValue; - -class QJsonParser { - friend class QJsonDocument; - -public: - QJsonParser(const char *begin, const char *end); - -public: - QJsonRoot *parse(); - -public: - QJsonParseError state() const; - -private: - static const char ArrayBegin = '['; - static const char ArrayEnd = ']'; - static const char NameSeparator = ':'; - static const char ValueSeparator = ','; - static const char ObjectBegin = '{'; - static const char ObjectEnd = '}'; - static const char Quote = '"'; - -private: - char peek(); - QJsonObject *getObject(); - QJsonArray *getArray(); - QJsonValue getValue(); - QString getString(); - QJsonValue getTrue(); - QJsonValue getFalse(); - QJsonValue getNull(); - QJsonValue getNumber(); - QPair getPair(); - -private: - void throwError(QJsonParseError::ParseError e); - -private: - QJsonParseError state_; - const char *const begin_; - const char *const end_; - const char * p_; -}; - -#endif - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +// NOTE: this is not part of the "public" Qt API, so using this class directly +// is not recomended + +#ifndef QJSON_PARSER_H_ +#define QJSON_PARSER_H_ + +#include + +#if QT_VERSION < 0x050000 + +#include "QJsonParseError.h" +#include +class QJsonRoot; +class QJsonObject; +class QJsonArray; +class QJsonValue; + +class QJsonParser { + friend class QJsonDocument; + +public: + QJsonParser(const char *begin, const char *end); + +public: + QJsonRoot *parse(); + +public: + QJsonParseError state() const; + +private: + static const char ArrayBegin = '['; + static const char ArrayEnd = ']'; + static const char NameSeparator = ':'; + static const char ValueSeparator = ','; + static const char ObjectBegin = '{'; + static const char ObjectEnd = '}'; + static const char Quote = '"'; + +private: + char peek(); + QJsonObject *getObject(); + QJsonArray *getArray(); + QJsonValue getValue(); + QString getString(); + QJsonValue getTrue(); + QJsonValue getFalse(); + QJsonValue getNull(); + QJsonValue getNumber(); + QPair getPair(); + +private: + void throwError(QJsonParseError::ParseError e); + +private: + QJsonParseError state_; + const char *const begin_; + const char *const end_; + const char * p_; +}; + +#endif + +#endif diff --git a/qjson4/QJsonRoot b/qjson4/QJsonRoot index fbcaca1..32bf3f0 100755 --- a/qjson4/QJsonRoot +++ b/qjson4/QJsonRoot @@ -1 +1 @@ -#include "QJsonRoot.h" +#include "QJsonRoot.h" diff --git a/qjson4/QJsonRoot.h b/qjson4/QJsonRoot.h index 77b9751..a7e0729 100755 --- a/qjson4/QJsonRoot.h +++ b/qjson4/QJsonRoot.h @@ -1,45 +1,45 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef QJSON_ROOT_H_ -#define QJSON_ROOT_H_ - -#include - -#if QT_VERSION < 0x050000 - -class QJsonObject; -class QJsonArray; - -class QJsonRoot { -public: - virtual ~QJsonRoot() {}; - -public: - virtual QJsonRoot *clone() const = 0; - -public: - virtual QJsonArray *toArray() = 0; - virtual QJsonObject *toObject() = 0; - virtual const QJsonArray *toArray() const = 0; - virtual const QJsonObject *toObject() const = 0; -}; - -#endif - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef QJSON_ROOT_H_ +#define QJSON_ROOT_H_ + +#include + +#if QT_VERSION < 0x050000 + +class QJsonObject; +class QJsonArray; + +class QJsonRoot { +public: + virtual ~QJsonRoot() {}; + +public: + virtual QJsonRoot *clone() const = 0; + +public: + virtual QJsonArray *toArray() = 0; + virtual QJsonObject *toObject() = 0; + virtual const QJsonArray *toArray() const = 0; + virtual const QJsonObject *toObject() const = 0; +}; + +#endif + +#endif diff --git a/qjson4/QJsonValue b/qjson4/QJsonValue index eb1b6fe..d4ca2b1 100755 --- a/qjson4/QJsonValue +++ b/qjson4/QJsonValue @@ -1 +1 @@ -#include "QJsonValue.h" +#include "QJsonValue.h" diff --git a/qjson4/QJsonValue.cpp b/qjson4/QJsonValue.cpp index 68bf87f..8365571 100755 --- a/qjson4/QJsonValue.cpp +++ b/qjson4/QJsonValue.cpp @@ -1,391 +1,391 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "QJsonValue.h" -#include "QJsonArray.h" -#include "QJsonObject.h" - -#if QT_VERSION < 0x050000 -#include -#include - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(Type type) : type_(type) { -} - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(bool b) : type_(Bool) { - value_.b = b; -} - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(double n) : type_(Double) { - value_.n = n; -} - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(const QString &s) : type_(String) { - value_.s = new QString(s); -} - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(QLatin1String s) : type_(String) { - value_.s = new QString(s); -} - -#ifndef QT_NO_CAST_FROM_ASCII -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(const char *s) : type_(String) { - value_.s = new QString(QString::fromUtf8(s)); -} -#endif - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(const QJsonArray &a) : type_(Array) { - value_.r = a.clone(); -} - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(const QJsonObject &o) : type_(Object) { - value_.r = o.clone(); -} - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(int n) : type_(Double) { - value_.n = n; -} - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(qint64 n) : type_(Double) { - value_.n = n; -} - -//------------------------------------------------------------------------------ -// Name: QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::QJsonValue(const QJsonValue &other) : type_(other.type_) { - - switch(other.type_) { - case Bool: - value_.b = other.value_.b; - break; - case Double: - value_.n = other.value_.n; - break; - case String: - value_.s = new QString(*other.value_.s); - break; - case Array: - case Object: - value_.r = other.value_.r->clone(); - break; - case Undefined: - case Null: - value_ = other.value_; - break; - } -} - -//------------------------------------------------------------------------------ -// Name: ~QJsonValue -//------------------------------------------------------------------------------ -QJsonValue::~QJsonValue() { - switch(type_) { - case Null: - case Bool: - case Double: - case Undefined: - break; - case String: - delete value_.s; - break; - case Object: - case Array: - delete value_.r; - break; - } -} - -//------------------------------------------------------------------------------ -// Name: operator= -//------------------------------------------------------------------------------ -QJsonValue &QJsonValue::operator=(const QJsonValue &other) { - QJsonValue(other).swap(*this); - return *this; -} - -//------------------------------------------------------------------------------ -// Name: operator!= -//------------------------------------------------------------------------------ -bool QJsonValue::operator!=(const QJsonValue &other) const { - return !(*this == other); -} - -//------------------------------------------------------------------------------ -// Name: operator== -//------------------------------------------------------------------------------ -bool QJsonValue::operator==(const QJsonValue &other) const { - if(type_ == other.type_) { - switch(type_) { - case Null: - return true; - case Bool: - return value_.b == other.value_.b; - case Double: - return value_.n == other.value_.n; - case Undefined: - return true; - case String: - return *value_.s == *other.value_.s; - case Array: - return *(value_.r->toArray()) == *(other.value_.r->toArray()); - case Object: - return *(value_.r->toObject()) == *(other.value_.r->toObject()); - } - } - return false; -} - -//------------------------------------------------------------------------------ -// Name: isArray -//------------------------------------------------------------------------------ -bool QJsonValue::isArray() const { - return type_ == Array; -} - -//------------------------------------------------------------------------------ -// Name: isBool -//------------------------------------------------------------------------------ -bool QJsonValue::isBool() const { - return type_ == Bool; -} - -//------------------------------------------------------------------------------ -// Name: isDouble -//------------------------------------------------------------------------------ -bool QJsonValue::isDouble() const { - return type_ == Double; -} - -//------------------------------------------------------------------------------ -// Name: isNull -//------------------------------------------------------------------------------ -bool QJsonValue::isNull() const { - return type_ == Null; -} - -//------------------------------------------------------------------------------ -// Name: isObject -//------------------------------------------------------------------------------ -bool QJsonValue::isObject() const { - return type_ == Object; -} - -//------------------------------------------------------------------------------ -// Name: isString -//------------------------------------------------------------------------------ -bool QJsonValue::isString() const { - return type_ == String; -} - -//------------------------------------------------------------------------------ -// Name: isUndefined -//------------------------------------------------------------------------------ -bool QJsonValue::isUndefined() const { - return type_ == Undefined; -} - -//------------------------------------------------------------------------------ -// Name: type -//------------------------------------------------------------------------------ -QJsonValue::Type QJsonValue::type() const { - return type_; -} - -//------------------------------------------------------------------------------ -// Name: toArray -//------------------------------------------------------------------------------ -QJsonArray QJsonValue::toArray(const QJsonArray &defaultValue) const { - if(isArray()) { - return *(value_.r->toArray()); - } - - return defaultValue; -} - -//------------------------------------------------------------------------------ -// Name: toArray -//------------------------------------------------------------------------------ -QJsonArray QJsonValue::toArray() const { - return toArray(QJsonArray()); -} - -//------------------------------------------------------------------------------ -// Name: toBool -//------------------------------------------------------------------------------ -bool QJsonValue::toBool(bool defaultValue) const { - if(isBool()) { - return value_.b; - } - - return defaultValue; -} - -//------------------------------------------------------------------------------ -// Name: toDouble -//------------------------------------------------------------------------------ -double QJsonValue::toDouble(double defaultValue) const { - if(isDouble()) { - return value_.n; - } - - return defaultValue; -} - -//------------------------------------------------------------------------------ -// Name: toInt -//------------------------------------------------------------------------------ -int QJsonValue::toInt(int defaultValue) const { - if(isDouble() && qFloor(value_.n) == value_.n) { - return value_.n; - } - - return defaultValue; -} - -//------------------------------------------------------------------------------ -// Name: toObject -//------------------------------------------------------------------------------ -QJsonObject QJsonValue::toObject(const QJsonObject &defaultValue) const { - if(isObject()) { - return *(value_.r->toObject()); - } - - return defaultValue; -} - -//------------------------------------------------------------------------------ -// Name: toObject -//------------------------------------------------------------------------------ -QJsonObject QJsonValue::toObject() const { - return toObject(QJsonObject()); -} - -//------------------------------------------------------------------------------ -// Name: toString -//------------------------------------------------------------------------------ -QString QJsonValue::toString(const QString &defaultValue) const { - - if(isString()) { - return *value_.s; - } - - return defaultValue; -} - -//------------------------------------------------------------------------------ -// Name: toVariant -//------------------------------------------------------------------------------ -QVariant QJsonValue::toVariant() const { - switch(type_) { - case Null: - return QVariant(); - case Bool: - return QVariant::fromValue(value_.b); - case Double: - return QVariant::fromValue(value_.n); - case String: - return QVariant::fromValue(*value_.s); - case Array: - return value_.r->toArray()->toVariantList(); - case Object: - return value_.r->toObject()->toVariantMap(); - case Undefined: - return QVariant(); - } - - return QVariant(); -} - -//------------------------------------------------------------------------------ -// Name: fromVariant -//------------------------------------------------------------------------------ -QJsonValue QJsonValue::fromVariant(const QVariant &variant) { - if(variant.isNull()) { - return QJsonValue(Null); - } - - switch(variant.type()) { - case QVariant::Bool: - return QJsonValue(variant.toBool()); - case QVariant::Int: - return QJsonValue(variant.toInt()); - case QVariant::Double: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::UInt: - return QJsonValue(variant.toDouble()); - case QVariant::String: - return QJsonValue(variant.toString()); - case QVariant::List: - return QJsonArray::fromVariantList(variant.toList()); - case QVariant::StringList: - return QJsonArray::fromStringList(variant.toStringList()); - case QVariant::Map: - return QJsonObject::fromVariantMap(variant.toMap()); - default: - const QString s = variant.toString(); - if(!s.isEmpty()) { - return QJsonValue(s); - } - break; - } - - return QJsonValue(Null); - -} - -//------------------------------------------------------------------------------ -// Name: swap -//------------------------------------------------------------------------------ -void QJsonValue::swap(QJsonValue &other) { - qSwap(type_, other.type_); - qSwap(value_, other.value_); -} - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "QJsonValue.h" +#include "QJsonArray.h" +#include "QJsonObject.h" + +#if QT_VERSION < 0x050000 +#include +#include + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(Type type) : type_(type) { +} + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(bool b) : type_(Bool) { + value_.b = b; +} + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(double n) : type_(Double) { + value_.n = n; +} + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(const QString &s) : type_(String) { + value_.s = new QString(s); +} + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(QLatin1String s) : type_(String) { + value_.s = new QString(s); +} + +#ifndef QT_NO_CAST_FROM_ASCII +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(const char *s) : type_(String) { + value_.s = new QString(QString::fromUtf8(s)); +} +#endif + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(const QJsonArray &a) : type_(Array) { + value_.r = a.clone(); +} + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(const QJsonObject &o) : type_(Object) { + value_.r = o.clone(); +} + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(int n) : type_(Double) { + value_.n = n; +} + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(qint64 n) : type_(Double) { + value_.n = n; +} + +//------------------------------------------------------------------------------ +// Name: QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::QJsonValue(const QJsonValue &other) : type_(other.type_) { + + switch(other.type_) { + case Bool: + value_.b = other.value_.b; + break; + case Double: + value_.n = other.value_.n; + break; + case String: + value_.s = new QString(*other.value_.s); + break; + case Array: + case Object: + value_.r = other.value_.r->clone(); + break; + case Undefined: + case Null: + value_ = other.value_; + break; + } +} + +//------------------------------------------------------------------------------ +// Name: ~QJsonValue +//------------------------------------------------------------------------------ +QJsonValue::~QJsonValue() { + switch(type_) { + case Null: + case Bool: + case Double: + case Undefined: + break; + case String: + delete value_.s; + break; + case Object: + case Array: + delete value_.r; + break; + } +} + +//------------------------------------------------------------------------------ +// Name: operator= +//------------------------------------------------------------------------------ +QJsonValue &QJsonValue::operator=(const QJsonValue &other) { + QJsonValue(other).swap(*this); + return *this; +} + +//------------------------------------------------------------------------------ +// Name: operator!= +//------------------------------------------------------------------------------ +bool QJsonValue::operator!=(const QJsonValue &other) const { + return !(*this == other); +} + +//------------------------------------------------------------------------------ +// Name: operator== +//------------------------------------------------------------------------------ +bool QJsonValue::operator==(const QJsonValue &other) const { + if(type_ == other.type_) { + switch(type_) { + case Null: + return true; + case Bool: + return value_.b == other.value_.b; + case Double: + return value_.n == other.value_.n; + case Undefined: + return true; + case String: + return *value_.s == *other.value_.s; + case Array: + return *(value_.r->toArray()) == *(other.value_.r->toArray()); + case Object: + return *(value_.r->toObject()) == *(other.value_.r->toObject()); + } + } + return false; +} + +//------------------------------------------------------------------------------ +// Name: isArray +//------------------------------------------------------------------------------ +bool QJsonValue::isArray() const { + return type_ == Array; +} + +//------------------------------------------------------------------------------ +// Name: isBool +//------------------------------------------------------------------------------ +bool QJsonValue::isBool() const { + return type_ == Bool; +} + +//------------------------------------------------------------------------------ +// Name: isDouble +//------------------------------------------------------------------------------ +bool QJsonValue::isDouble() const { + return type_ == Double; +} + +//------------------------------------------------------------------------------ +// Name: isNull +//------------------------------------------------------------------------------ +bool QJsonValue::isNull() const { + return type_ == Null; +} + +//------------------------------------------------------------------------------ +// Name: isObject +//------------------------------------------------------------------------------ +bool QJsonValue::isObject() const { + return type_ == Object; +} + +//------------------------------------------------------------------------------ +// Name: isString +//------------------------------------------------------------------------------ +bool QJsonValue::isString() const { + return type_ == String; +} + +//------------------------------------------------------------------------------ +// Name: isUndefined +//------------------------------------------------------------------------------ +bool QJsonValue::isUndefined() const { + return type_ == Undefined; +} + +//------------------------------------------------------------------------------ +// Name: type +//------------------------------------------------------------------------------ +QJsonValue::Type QJsonValue::type() const { + return type_; +} + +//------------------------------------------------------------------------------ +// Name: toArray +//------------------------------------------------------------------------------ +QJsonArray QJsonValue::toArray(const QJsonArray &defaultValue) const { + if(isArray()) { + return *(value_.r->toArray()); + } + + return defaultValue; +} + +//------------------------------------------------------------------------------ +// Name: toArray +//------------------------------------------------------------------------------ +QJsonArray QJsonValue::toArray() const { + return toArray(QJsonArray()); +} + +//------------------------------------------------------------------------------ +// Name: toBool +//------------------------------------------------------------------------------ +bool QJsonValue::toBool(bool defaultValue) const { + if(isBool()) { + return value_.b; + } + + return defaultValue; +} + +//------------------------------------------------------------------------------ +// Name: toDouble +//------------------------------------------------------------------------------ +double QJsonValue::toDouble(double defaultValue) const { + if(isDouble()) { + return value_.n; + } + + return defaultValue; +} + +//------------------------------------------------------------------------------ +// Name: toInt +//------------------------------------------------------------------------------ +int QJsonValue::toInt(int defaultValue) const { + if(isDouble() && qFloor(value_.n) == value_.n) { + return value_.n; + } + + return defaultValue; +} + +//------------------------------------------------------------------------------ +// Name: toObject +//------------------------------------------------------------------------------ +QJsonObject QJsonValue::toObject(const QJsonObject &defaultValue) const { + if(isObject()) { + return *(value_.r->toObject()); + } + + return defaultValue; +} + +//------------------------------------------------------------------------------ +// Name: toObject +//------------------------------------------------------------------------------ +QJsonObject QJsonValue::toObject() const { + return toObject(QJsonObject()); +} + +//------------------------------------------------------------------------------ +// Name: toString +//------------------------------------------------------------------------------ +QString QJsonValue::toString(const QString &defaultValue) const { + + if(isString()) { + return *value_.s; + } + + return defaultValue; +} + +//------------------------------------------------------------------------------ +// Name: toVariant +//------------------------------------------------------------------------------ +QVariant QJsonValue::toVariant() const { + switch(type_) { + case Null: + return QVariant(); + case Bool: + return QVariant::fromValue(value_.b); + case Double: + return QVariant::fromValue(value_.n); + case String: + return QVariant::fromValue(*value_.s); + case Array: + return value_.r->toArray()->toVariantList(); + case Object: + return value_.r->toObject()->toVariantMap(); + case Undefined: + return QVariant(); + } + + return QVariant(); +} + +//------------------------------------------------------------------------------ +// Name: fromVariant +//------------------------------------------------------------------------------ +QJsonValue QJsonValue::fromVariant(const QVariant &variant) { + if(variant.isNull()) { + return QJsonValue(Null); + } + + switch(variant.type()) { + case QVariant::Bool: + return QJsonValue(variant.toBool()); + case QVariant::Int: + return QJsonValue(variant.toInt()); + case QVariant::Double: + case QVariant::LongLong: + case QVariant::ULongLong: + case QVariant::UInt: + return QJsonValue(variant.toDouble()); + case QVariant::String: + return QJsonValue(variant.toString()); + case QVariant::List: + return QJsonArray::fromVariantList(variant.toList()); + case QVariant::StringList: + return QJsonArray::fromStringList(variant.toStringList()); + case QVariant::Map: + return QJsonObject::fromVariantMap(variant.toMap()); + default: + const QString s = variant.toString(); + if(!s.isEmpty()) { + return QJsonValue(s); + } + break; + } + + return QJsonValue(Null); + +} + +//------------------------------------------------------------------------------ +// Name: swap +//------------------------------------------------------------------------------ +void QJsonValue::swap(QJsonValue &other) { + qSwap(type_, other.type_); + qSwap(value_, other.value_); +} + +#endif diff --git a/qjson4/QJsonValue.h b/qjson4/QJsonValue.h index bf32898..dec14aa 100755 --- a/qjson4/QJsonValue.h +++ b/qjson4/QJsonValue.h @@ -1,120 +1,120 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef QJSON_VALUE_H_ -#define QJSON_VALUE_H_ - -#include - -#if QT_VERSION >= 0x050000 -#include -#else - -class QString; - -#include - -class QJsonRoot; -class QJsonArray; -class QJsonObject; - -class QJsonValue { -public: - enum Type { - Null = 0x0, - Bool = 0x1, - Double = 0x2, - String = 0x3, - Array = 0x4, - Object = 0x5, - Undefined = 0x80 - }; - -public: - QJsonValue(Type type = Null); - QJsonValue(bool b); - QJsonValue(double n); - QJsonValue(int n); - QJsonValue(qint64 n); - QJsonValue(const QString &s); - QJsonValue(QLatin1String s); -#ifndef QT_NO_CAST_FROM_ASCII - QJsonValue(const char *s); -#endif - QJsonValue(const QJsonArray &a); - QJsonValue(const QJsonObject &o); - QJsonValue(const QJsonValue &other); - - ~QJsonValue(); - -private: - // to protect against incorrect usage due to passing a const char * - QJsonValue(const void *); - -public: - QJsonValue &operator=(const QJsonValue &other); - -public: - bool operator!=(const QJsonValue &other) const; - bool operator==(const QJsonValue &other) const; - -public: - bool isArray() const; - bool isBool() const; - bool isDouble() const; - bool isNull() const; - bool isObject() const; - bool isString() const; - bool isUndefined() const; - -public: - QJsonArray toArray(const QJsonArray &defaultValue) const; - QJsonArray toArray() const; - bool toBool(bool defaultValue = false) const; - double toDouble(double defaultValue = 0) const; - int toInt(int defaultValue = 0) const; - QJsonObject toObject(const QJsonObject &defaultValue) const; - QJsonObject toObject() const; - QString toString(const QString &defaultValue = QString()) const; - QVariant toVariant() const; - -public: - Type type() const; - -public: - static QJsonValue fromVariant(const QVariant &variant); - -private: - void swap(QJsonValue &other); - -private: - Type type_; - - union ValueType { - bool b; - double n; - QString *s; - QJsonRoot *r; // OJsonObject or QJsonArray - }; - - ValueType value_; -}; - -#endif - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef QJSON_VALUE_H_ +#define QJSON_VALUE_H_ + +#include + +#if QT_VERSION >= 0x050000 +#include +#else + +class QString; + +#include + +class QJsonRoot; +class QJsonArray; +class QJsonObject; + +class QJsonValue { +public: + enum Type { + Null = 0x0, + Bool = 0x1, + Double = 0x2, + String = 0x3, + Array = 0x4, + Object = 0x5, + Undefined = 0x80 + }; + +public: + QJsonValue(Type type = Null); + QJsonValue(bool b); + QJsonValue(double n); + QJsonValue(int n); + QJsonValue(qint64 n); + QJsonValue(const QString &s); + QJsonValue(QLatin1String s); +#ifndef QT_NO_CAST_FROM_ASCII + QJsonValue(const char *s); +#endif + QJsonValue(const QJsonArray &a); + QJsonValue(const QJsonObject &o); + QJsonValue(const QJsonValue &other); + + ~QJsonValue(); + +private: + // to protect against incorrect usage due to passing a const char * + QJsonValue(const void *); + +public: + QJsonValue &operator=(const QJsonValue &other); + +public: + bool operator!=(const QJsonValue &other) const; + bool operator==(const QJsonValue &other) const; + +public: + bool isArray() const; + bool isBool() const; + bool isDouble() const; + bool isNull() const; + bool isObject() const; + bool isString() const; + bool isUndefined() const; + +public: + QJsonArray toArray(const QJsonArray &defaultValue) const; + QJsonArray toArray() const; + bool toBool(bool defaultValue = false) const; + double toDouble(double defaultValue = 0) const; + int toInt(int defaultValue = 0) const; + QJsonObject toObject(const QJsonObject &defaultValue) const; + QJsonObject toObject() const; + QString toString(const QString &defaultValue = QString()) const; + QVariant toVariant() const; + +public: + Type type() const; + +public: + static QJsonValue fromVariant(const QVariant &variant); + +private: + void swap(QJsonValue &other); + +private: + Type type_; + + union ValueType { + bool b; + double n; + QString *s; + QJsonRoot *r; // OJsonObject or QJsonArray + }; + + ValueType value_; +}; + +#endif + +#endif diff --git a/qjson4/QJsonValueRef b/qjson4/QJsonValueRef index f3b6811..f106170 100755 --- a/qjson4/QJsonValueRef +++ b/qjson4/QJsonValueRef @@ -1 +1 @@ -#include "QJsonValueRef.h" +#include "QJsonValueRef.h" diff --git a/qjson4/QJsonValueRef.cpp b/qjson4/QJsonValueRef.cpp index 7d67ef4..386d056 100755 --- a/qjson4/QJsonValueRef.cpp +++ b/qjson4/QJsonValueRef.cpp @@ -1,228 +1,228 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "QJsonValueRef.h" - -#if QT_VERSION < 0x050000 - -#include "QJsonArray.h" -#include "QJsonObject.h" - -//------------------------------------------------------------------------------ -// Name: -// Desc: -//------------------------------------------------------------------------------ -QJsonValueRef::QJsonValueRef(QJsonArray *array, int idx) : p_(array), index_(idx) { -} - -//------------------------------------------------------------------------------ -// Name: -// Desc: -//------------------------------------------------------------------------------ -QJsonValueRef::QJsonValueRef(QJsonObject *object, const QString &key) : p_(object), index_(0), key_(key) { -} - -//------------------------------------------------------------------------------ -// Name: -// Desc: -//------------------------------------------------------------------------------ -QJsonValueRef::operator QJsonValue() const { - return toValue(); -} - -//------------------------------------------------------------------------------ -// Name: -// Desc: -//------------------------------------------------------------------------------ -QJsonValueRef &QJsonValueRef::operator=(const QJsonValue &val) { - - if(QJsonObject *const o = p_->toObject()) { - o->values_[key_] = val; - } else if(QJsonArray *const a = p_->toArray()) { - a->values_[index_] = val; - } - return *this; -} - -//------------------------------------------------------------------------------ -// Name: -// Desc: -//------------------------------------------------------------------------------ -QJsonValueRef &QJsonValueRef::operator=(const QJsonValueRef &ref) { - - if(QJsonObject *const o = p_->toObject()) { - o->values_[key_] = ref; - } else if(QJsonArray *const a = p_->toArray()) { - a->values_[index_] = ref; - } - return *this; -} - -//------------------------------------------------------------------------------ -// Name: type -// Desc: -//------------------------------------------------------------------------------ -QJsonValue::Type QJsonValueRef::type() const { - return toValue().type(); -} - -//------------------------------------------------------------------------------ -// Name: isNull -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::isNull() const { - return toValue().isNull(); -} - -//------------------------------------------------------------------------------ -// Name: isBool -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::isBool() const { - return toValue().isBool(); -} - -//------------------------------------------------------------------------------ -// Name: isDouble -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::isDouble() const { - return toValue().isDouble(); -} - -//------------------------------------------------------------------------------ -// Name: isString -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::isString() const { - return toValue().isString(); -} - -//------------------------------------------------------------------------------ -// Name: isArray -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::isArray() const { - return toValue().isArray(); -} - -//------------------------------------------------------------------------------ -// Name: isObject -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::isObject() const { - return toValue().isObject(); -} - -//------------------------------------------------------------------------------ -// Name: isUndefined -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::isUndefined() const { - return toValue().isUndefined(); -} - -//------------------------------------------------------------------------------ -// Name: toBool -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::toBool() const { - return toValue().toBool(); -} - -//------------------------------------------------------------------------------ -// Name: toDouble -// Desc: -//------------------------------------------------------------------------------ -double QJsonValueRef::toDouble() const { - return toValue().toDouble(); -} - -//------------------------------------------------------------------------------ -// Name: toInt -// Desc: -//------------------------------------------------------------------------------ -int QJsonValueRef::toInt(int defaultValue) const { - return toValue().toInt(defaultValue); -} - -//------------------------------------------------------------------------------ -// Name: toString -// Desc: -//------------------------------------------------------------------------------ -QString QJsonValueRef::toString() const { - return toValue().toString(); -} - -//------------------------------------------------------------------------------ -// Name: toArray -// Desc: -//------------------------------------------------------------------------------ -QJsonArray QJsonValueRef::toArray() const { - return toValue().toArray(); -} - -//------------------------------------------------------------------------------ -// Name: toObject -// Desc: -//------------------------------------------------------------------------------ -QJsonObject QJsonValueRef::toObject() const { - return toValue().toObject(); -} - -//------------------------------------------------------------------------------ -// Name: operator== -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::operator==(const QJsonValue &other) const { - return toValue() == other; -} - -//------------------------------------------------------------------------------ -// Name: operator!= -// Desc: -//------------------------------------------------------------------------------ -bool QJsonValueRef::operator!=(const QJsonValue &other) const { - return toValue() != other; -} - -//------------------------------------------------------------------------------ -// Name: toValue -// Desc: -//------------------------------------------------------------------------------ -QJsonValue QJsonValueRef::toValue() const { - if(QJsonObject *const o = p_->toObject()) { - return o->values_[key_]; - } else if(QJsonArray *const a = p_->toArray()) { - return a->values_[index_]; - } - - return QJsonValue(); -} - -//------------------------------------------------------------------------------ -// Name: swap -// Desc: -//------------------------------------------------------------------------------ -void QJsonValueRef::swap(QJsonValueRef &other) { - qSwap(p_, other.p_); - qSwap(key_, other.key_); - qSwap(index_, other.index_); -} - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "QJsonValueRef.h" + +#if QT_VERSION < 0x050000 + +#include "QJsonArray.h" +#include "QJsonObject.h" + +//------------------------------------------------------------------------------ +// Name: +// Desc: +//------------------------------------------------------------------------------ +QJsonValueRef::QJsonValueRef(QJsonArray *array, int idx) : p_(array), index_(idx) { +} + +//------------------------------------------------------------------------------ +// Name: +// Desc: +//------------------------------------------------------------------------------ +QJsonValueRef::QJsonValueRef(QJsonObject *object, const QString &key) : p_(object), index_(0), key_(key) { +} + +//------------------------------------------------------------------------------ +// Name: +// Desc: +//------------------------------------------------------------------------------ +QJsonValueRef::operator QJsonValue() const { + return toValue(); +} + +//------------------------------------------------------------------------------ +// Name: +// Desc: +//------------------------------------------------------------------------------ +QJsonValueRef &QJsonValueRef::operator=(const QJsonValue &val) { + + if(QJsonObject *const o = p_->toObject()) { + o->values_[key_] = val; + } else if(QJsonArray *const a = p_->toArray()) { + a->values_[index_] = val; + } + return *this; +} + +//------------------------------------------------------------------------------ +// Name: +// Desc: +//------------------------------------------------------------------------------ +QJsonValueRef &QJsonValueRef::operator=(const QJsonValueRef &ref) { + + if(QJsonObject *const o = p_->toObject()) { + o->values_[key_] = ref; + } else if(QJsonArray *const a = p_->toArray()) { + a->values_[index_] = ref; + } + return *this; +} + +//------------------------------------------------------------------------------ +// Name: type +// Desc: +//------------------------------------------------------------------------------ +QJsonValue::Type QJsonValueRef::type() const { + return toValue().type(); +} + +//------------------------------------------------------------------------------ +// Name: isNull +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::isNull() const { + return toValue().isNull(); +} + +//------------------------------------------------------------------------------ +// Name: isBool +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::isBool() const { + return toValue().isBool(); +} + +//------------------------------------------------------------------------------ +// Name: isDouble +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::isDouble() const { + return toValue().isDouble(); +} + +//------------------------------------------------------------------------------ +// Name: isString +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::isString() const { + return toValue().isString(); +} + +//------------------------------------------------------------------------------ +// Name: isArray +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::isArray() const { + return toValue().isArray(); +} + +//------------------------------------------------------------------------------ +// Name: isObject +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::isObject() const { + return toValue().isObject(); +} + +//------------------------------------------------------------------------------ +// Name: isUndefined +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::isUndefined() const { + return toValue().isUndefined(); +} + +//------------------------------------------------------------------------------ +// Name: toBool +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::toBool() const { + return toValue().toBool(); +} + +//------------------------------------------------------------------------------ +// Name: toDouble +// Desc: +//------------------------------------------------------------------------------ +double QJsonValueRef::toDouble() const { + return toValue().toDouble(); +} + +//------------------------------------------------------------------------------ +// Name: toInt +// Desc: +//------------------------------------------------------------------------------ +int QJsonValueRef::toInt(int defaultValue) const { + return toValue().toInt(defaultValue); +} + +//------------------------------------------------------------------------------ +// Name: toString +// Desc: +//------------------------------------------------------------------------------ +QString QJsonValueRef::toString() const { + return toValue().toString(); +} + +//------------------------------------------------------------------------------ +// Name: toArray +// Desc: +//------------------------------------------------------------------------------ +QJsonArray QJsonValueRef::toArray() const { + return toValue().toArray(); +} + +//------------------------------------------------------------------------------ +// Name: toObject +// Desc: +//------------------------------------------------------------------------------ +QJsonObject QJsonValueRef::toObject() const { + return toValue().toObject(); +} + +//------------------------------------------------------------------------------ +// Name: operator== +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::operator==(const QJsonValue &other) const { + return toValue() == other; +} + +//------------------------------------------------------------------------------ +// Name: operator!= +// Desc: +//------------------------------------------------------------------------------ +bool QJsonValueRef::operator!=(const QJsonValue &other) const { + return toValue() != other; +} + +//------------------------------------------------------------------------------ +// Name: toValue +// Desc: +//------------------------------------------------------------------------------ +QJsonValue QJsonValueRef::toValue() const { + if(QJsonObject *const o = p_->toObject()) { + return o->values_[key_]; + } else if(QJsonArray *const a = p_->toArray()) { + return a->values_[index_]; + } + + return QJsonValue(); +} + +//------------------------------------------------------------------------------ +// Name: swap +// Desc: +//------------------------------------------------------------------------------ +void QJsonValueRef::swap(QJsonValueRef &other) { + qSwap(p_, other.p_); + qSwap(key_, other.key_); + qSwap(index_, other.index_); +} + +#endif diff --git a/qjson4/QJsonValueRef.h b/qjson4/QJsonValueRef.h index 567c68a..292f37b 100755 --- a/qjson4/QJsonValueRef.h +++ b/qjson4/QJsonValueRef.h @@ -1,79 +1,79 @@ -/***************************************************************************** -* gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef QJSON_VALUEREF_H_ -#define QJSON_VALUEREF_H_ - -#include - -#if QT_VERSION >= 0x050000 -#include -#else - -#include "QJsonValue.h" -class QJsonRoot; - -class QJsonValueRef { -public: - QJsonValueRef(QJsonArray *array, int idx); - - // slight variant from official APIs implementation - QJsonValueRef(QJsonObject *object, const QString &key); - -public: - operator QJsonValue() const; - -public: - QJsonValueRef &operator=(const QJsonValue &val); - QJsonValueRef &operator=(const QJsonValueRef &val); - -public: - QJsonValue::Type type() const; - bool isNull() const; - bool isBool() const; - bool isDouble() const; - bool isString() const; - bool isArray() const; - bool isObject() const; - bool isUndefined() const; - -public: - bool toBool() const; - double toDouble() const; - QString toString() const; - QJsonArray toArray() const; - QJsonObject toObject() const; - int toInt(int defaultValue = 0) const; - -public: - bool operator==(const QJsonValue &other) const; - bool operator!=(const QJsonValue &other) const; - -private: - QJsonValue toValue() const; - void swap(QJsonValueRef &other); - -private: - QJsonRoot *p_; - int index_; - QString key_; -}; - -#endif - -#endif +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef QJSON_VALUEREF_H_ +#define QJSON_VALUEREF_H_ + +#include + +#if QT_VERSION >= 0x050000 +#include +#else + +#include "QJsonValue.h" +class QJsonRoot; + +class QJsonValueRef { +public: + QJsonValueRef(QJsonArray *array, int idx); + + // slight variant from official APIs implementation + QJsonValueRef(QJsonObject *object, const QString &key); + +public: + operator QJsonValue() const; + +public: + QJsonValueRef &operator=(const QJsonValue &val); + QJsonValueRef &operator=(const QJsonValueRef &val); + +public: + QJsonValue::Type type() const; + bool isNull() const; + bool isBool() const; + bool isDouble() const; + bool isString() const; + bool isArray() const; + bool isObject() const; + bool isUndefined() const; + +public: + bool toBool() const; + double toDouble() const; + QString toString() const; + QJsonArray toArray() const; + QJsonObject toObject() const; + int toInt(int defaultValue = 0) const; + +public: + bool operator==(const QJsonValue &other) const; + bool operator!=(const QJsonValue &other) const; + +private: + QJsonValue toValue() const; + void swap(QJsonValueRef &other); + +private: + QJsonRoot *p_; + int index_; + QString key_; +}; + +#endif + +#endif diff --git a/res/app.rc b/res/app.rc index c29043b..9195aef 100755 --- a/res/app.rc +++ b/res/app.rc @@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest" #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 1, 3, 3, 0 -PRODUCTVERSION 1, 3, 3, 0 +FILEVERSION 1, 4, 0, 0 +PRODUCTVERSION 1, 4, 0, 0 FILEFLAGSMASK 0x3fL FILEFLAGS 0 FILEOS VOS_NT_WINDOWS32 @@ -25,12 +25,12 @@ BEGIN BEGIN VALUE "CompanyName", "Syping" VALUE "FileDescription", "gta5view\0" - VALUE "FileVersion", "1.3.3\0" + VALUE "FileVersion", "1.4.0-dev1\0" VALUE "InternalName", "gta5view\0" VALUE "LegalCopyright", "Copyright 2016-2017 Syping\0" VALUE "OriginalFilename", "gta5view.exe\0" VALUE "ProductName", "gta5view\0" - VALUE "ProductVersion", "1.3.3\0" + VALUE "ProductVersion", "1.4.0-dev1\0" END END END diff --git a/res/avatarareaimport.png b/res/avatarareaimport.png index 045c9619cb635f630b28f060841fd9f927f36aeb..97c53cfa828232a241848e7adde7c63ab7da4961 100644 GIT binary patch delta 36 scmX>jbW>=9Av0%5kY6x^!?PP{lXaPOIGGvQ84S+4MM`f@Vt&O60NbPsLjV8( delta 26 icmca9bVg`{A@gKAW(`gzPDV4vmv^`B+?>z+iWLBK{0Tk) diff --git a/res/global.de.ini b/res/global.de.ini index fea6010..5b2d94f 100755 --- a/res/global.de.ini +++ b/res/global.de.ini @@ -1,102 +1,102 @@ -[Global] -AIRP="Internationaler Flughafen von LS" -ALAMO="Alamosee" -ALTA="Alta" -ARMYB="Fort Zancudo" -BANNING="Banning" -BAYTRE="Baytree Canyon" -BEACH="Vespucci Beach" -BHAMCA="Banham Canyon" -BRADP="Braddock-Pass" -BRADT="Braddock-Tunnel" -BURTON="Burton" -CALAFB="Calafia-Brücke" -CANNY="Raton Canyon" -CCREAK="Cassidy Creek" -CHAMH="Chamberlain Hills" -CHIL="Vinewood Hills" -CHU="Chumash" -CMSW="Chiliad-Mountain-Naturschutzgebiet" -COSI="Vorstädte" -CYPRE="Cypress Flats" -DAVIS="Davis" -DELBE="Del Perro Beach" -DELPE="Del Perro" -DELSOL="La Puerta" -DESRT="Grand-Senora-Wüste" -DOWNT="Innenstadt" -DTVINE="Vinewood Mitte" -EAST_V="East Vinewood" -EBURO="El Burro Heights" -ECLIPS="Eclipse" -ELGORL="Leuchtturm El Gordo" -ELSANT="East Los Santos" -ELYSIAN="Elysian Island" -GALFISH="Galilee" -GALLI="Galileo-Park" -GOLF="GWC und Golfclub" -GRAPES="Grapeseed" -GREATC="Great Chaparral" -HARMO="Harmony" -HAWICK="Hawick" -HEART="Heart Attacks Beach" -HORS="Vinewood-Rennbahn" -HUD_MG_TRI_ALA="Alamosee" -HUD_MG_TRI_VES="Vespucci" -HUMLAB="Humane Labs and Research" -JAIL="Bolingbroke-Strafanstalt" -KOREAT="Little Seoul" -LACT="Land-Act-Stausee" -LAGO="Lago Zancudo" -LDAM="Land-Act-Staudamm" -LMESA="La Mesa" -LOSPUER="La Puerta" -LOSSF="Los Santos Freeway" -MGCR_1="South Los Santos" -MGSR_3="Raton Canyon" -MIRR="Mirror Park" -MORN="Morningwood" -MOVIE="Richards Majestic" -MTCHIL="Mount Chiliad" -MTGORDO="Mount Gordo" -MTJOSE="Mount Josiah" -MURRI="Murrieta Heights" -NCHU="North Chumash" -OBSERV="Galileo-Observatorium" -OCEANA="Pazifik" -PALCOV="Paleto Cove" -PALETO="Paleto Bay" -PALFOR="Paleto Forest" -PALHIGH="Palomino-Hochland" -PALMPOW="Palmer-Taylor-Elektrizitätswerk" -PBLUFF="Pacific Bluffs" -PBOX="Pillbox Hill" -PROCOB="Procopio Beach" -PROL="North Yankton" -RANCHO="Rancho" -RGLEN="Richman Glen" -RICHM="Richman" -ROCKF="Rockford Hills" -RTRAK="Redwood-Lights-Rennstrecke" -SANAND="San Andreas" -SANCHIA="San-Chianski-Bergkette" -SANDY="Sandy Shores" -SKID="Mission Row" -SLAB="Stab City" -SLSANT="South Los Santos" -STAD="Maze Bank Arena" -STRAW="Strawberry" -TATAMO="Tataviam-Bergkette" -TERMINA="Terminal" -TEXTI="Textilbezirk" -TONGVAH="Tongva Hills" -TONGVAV="Tongva Valley" -UTOPIAG="Utopia Gardens" -VCANA="Vespucci-Kanäle" -VESP="Vespucci" -VINE="Vinewood" -WINDF="Ron-Alternates-Windpark" -WMIRROR="West Mirror Drive" -WVINE="Vinewood West" -ZANCUDO="Zancudo River" -ZENORA="Senora Freeway" +[Global] +AIRP="Internationaler Flughafen von LS" +ALAMO="Alamosee" +ALTA="Alta" +ARMYB="Fort Zancudo" +BANNING="Banning" +BAYTRE="Baytree Canyon" +BEACH="Vespucci Beach" +BHAMCA="Banham Canyon" +BRADP="Braddock-Pass" +BRADT="Braddock-Tunnel" +BURTON="Burton" +CALAFB="Calafia-Brücke" +CANNY="Raton Canyon" +CCREAK="Cassidy Creek" +CHAMH="Chamberlain Hills" +CHIL="Vinewood Hills" +CHU="Chumash" +CMSW="Chiliad-Mountain-Naturschutzgebiet" +COSI="Vorstädte" +CYPRE="Cypress Flats" +DAVIS="Davis" +DELBE="Del Perro Beach" +DELPE="Del Perro" +DELSOL="La Puerta" +DESRT="Grand-Senora-Wüste" +DOWNT="Innenstadt" +DTVINE="Vinewood Mitte" +EAST_V="East Vinewood" +EBURO="El Burro Heights" +ECLIPS="Eclipse" +ELGORL="Leuchtturm El Gordo" +ELSANT="East Los Santos" +ELYSIAN="Elysian Island" +GALFISH="Galilee" +GALLI="Galileo-Park" +GOLF="GWC und Golfclub" +GRAPES="Grapeseed" +GREATC="Great Chaparral" +HARMO="Harmony" +HAWICK="Hawick" +HEART="Heart Attacks Beach" +HORS="Vinewood-Rennbahn" +HUD_MG_TRI_ALA="Alamosee" +HUD_MG_TRI_VES="Vespucci" +HUMLAB="Humane Labs and Research" +JAIL="Bolingbroke-Strafanstalt" +KOREAT="Little Seoul" +LACT="Land-Act-Stausee" +LAGO="Lago Zancudo" +LDAM="Land-Act-Staudamm" +LMESA="La Mesa" +LOSPUER="La Puerta" +LOSSF="Los Santos Freeway" +MGCR_1="South Los Santos" +MGSR_3="Raton Canyon" +MIRR="Mirror Park" +MORN="Morningwood" +MOVIE="Richards Majestic" +MTCHIL="Mount Chiliad" +MTGORDO="Mount Gordo" +MTJOSE="Mount Josiah" +MURRI="Murrieta Heights" +NCHU="North Chumash" +OBSERV="Galileo-Observatorium" +OCEANA="Pazifik" +PALCOV="Paleto Cove" +PALETO="Paleto Bay" +PALFOR="Paleto Forest" +PALHIGH="Palomino-Hochland" +PALMPOW="Palmer-Taylor-Elektrizitätswerk" +PBLUFF="Pacific Bluffs" +PBOX="Pillbox Hill" +PROCOB="Procopio Beach" +PROL="North Yankton" +RANCHO="Rancho" +RGLEN="Richman Glen" +RICHM="Richman" +ROCKF="Rockford Hills" +RTRAK="Redwood-Lights-Rennstrecke" +SANAND="San Andreas" +SANCHIA="San-Chianski-Bergkette" +SANDY="Sandy Shores" +SKID="Mission Row" +SLAB="Stab City" +SLSANT="South Los Santos" +STAD="Maze Bank Arena" +STRAW="Strawberry" +TATAMO="Tataviam-Bergkette" +TERMINA="Terminal" +TEXTI="Textilbezirk" +TONGVAH="Tongva Hills" +TONGVAV="Tongva Valley" +UTOPIAG="Utopia Gardens" +VCANA="Vespucci-Kanäle" +VESP="Vespucci" +VINE="Vinewood" +WINDF="Ron-Alternates-Windpark" +WMIRROR="West Mirror Drive" +WVINE="Vinewood West" +ZANCUDO="Zancudo River" +ZENORA="Senora Freeway" diff --git a/res/global.en.ini b/res/global.en.ini index 4c31ad3..375c91c 100755 --- a/res/global.en.ini +++ b/res/global.en.ini @@ -1,103 +1,103 @@ -[Global] -AIRP="Los Santos International Airport" -ALAMO="Alamo Sea" -ALTA="Alta" -ARMYB="Fort Zancudo" -BANNING="Banning" -BAYTRE="Baytree Canyon" -BEACH="Vespucci Beach" -BHAMCA="Banham Canyon" -BRADP="Braddock Pass" -BRADT="Braddock Tunnel" -BURTON="Burton" -CALAFB="Calafia Bridge" -CANNY="Raton Canyon" -CCREAK="Cassidy Creek" -CHAMH="Chamberlain Hills" -CHIL="Vinewood Hills" -CHU="Chumash" -CMSW="Chiliad Mountain State Wilderness" -COSI="Countryside" -CYPRE="Cypress Flats" -DAVIS="Davis" -DELBE="Del Perro Beach" -DELPE="Del Perro" -DELSOL="La Puerta" -DESRT="Grand Senora Desert" -DOWNT="Downtown" -DTVINE="Downtown Vinewood" -EAST_V="East Vinewood" -EBURO="El Burro Heights" -ECLIPS="Eclipse" -ELGORL="El Gordo Lighthouse" -ELSANT="East Los Santos" -ELYSIAN="Elysian Island" -GALFISH="Galilee" -GALLI="Galileo Park" -GOLF="GWC and Golfing Society" -GRAPES="Grapeseed" -GREATC="Great Chaparral" -HARMO="Harmony" -HAWICK="Hawick" -HEART="Heart Attacks Beach" -HORS="Vinewood Racetrack" -HUD_MG_TRI_ALA="Alamo Sea" -HUD_MG_TRI_VES="Vespucci" -HUMLAB="Humane Labs and Research" -JAIL="Bolingbroke Penitentiary" -KOREAT="Little Seoul" -LACT="Land Act Reservoir" -LAGO="Lago Zancudo" -LDAM="Land Act Dam" -LMESA="La Mesa" -LOSPUER="La Puerta" -LOSSF="Los Santos Freeway" -MGCR_1="South Los Santos" -MGCR_6="Vespucci Canals" -MGSR_3="Raton Canyon" -MIRR="Mirror Park" -MORN="Morningwood" -MOVIE="Richards Majestic" -MTCHIL="Mount Chiliad" -MTGORDO="Mount Gordo" -MTJOSE="Mount Josiah" -MURRI="Murrieta Heights" -NCHU="North Chumash" -OBSERV="Galileo Observatory" -OCEANA="Pacific Ocean" -PALCOV="Paleto Cove" -PALETO="Paleto Bay" -PALFOR="Paleto Forest" -PALHIGH="Palomino Highlands" -PALMPOW="Palmer-Taylor Power Station" -PBLUFF="Pacific Bluffs" -PBOX="Pillbox Hill" -PROCOB="Procopio Beach" -PROL="North Yankton" -RANCHO="Rancho" -RGLEN="Richman Glen" -RICHM="Richman" -ROCKF="Rockford Hills" -RTRAK="Redwood Lights Track" -SANAND="San Andreas" -SANCHIA="San Chianski Mountain Range" -SANDY="Sandy Shores" -SKID="Mission Row" -SLAB="Stab City" -SLSANT="South Los Santos" -STAD="Maze Bank Arena" -STRAW="Strawberry" -TATAMO="Tataviam Mountains" -TERMINA="Terminal" -TEXTI="Textile City" -TONGVAH="Tongva Hills" -TONGVAV="Tongva Valley" -UTOPIAG="Utopia Gardens" -VCANA="Vespucci Canals" -VESP="Vespucci" -VINE="Vinewood" -WINDF="Ron Alternates Wind Farm" -WMIRROR="West Mirror Drive" -WVINE="West Vinewood" -ZANCUDO="Zancudo River" -ZENORA="Senora Freeway" +[Global] +AIRP="Los Santos International Airport" +ALAMO="Alamo Sea" +ALTA="Alta" +ARMYB="Fort Zancudo" +BANNING="Banning" +BAYTRE="Baytree Canyon" +BEACH="Vespucci Beach" +BHAMCA="Banham Canyon" +BRADP="Braddock Pass" +BRADT="Braddock Tunnel" +BURTON="Burton" +CALAFB="Calafia Bridge" +CANNY="Raton Canyon" +CCREAK="Cassidy Creek" +CHAMH="Chamberlain Hills" +CHIL="Vinewood Hills" +CHU="Chumash" +CMSW="Chiliad Mountain State Wilderness" +COSI="Countryside" +CYPRE="Cypress Flats" +DAVIS="Davis" +DELBE="Del Perro Beach" +DELPE="Del Perro" +DELSOL="La Puerta" +DESRT="Grand Senora Desert" +DOWNT="Downtown" +DTVINE="Downtown Vinewood" +EAST_V="East Vinewood" +EBURO="El Burro Heights" +ECLIPS="Eclipse" +ELGORL="El Gordo Lighthouse" +ELSANT="East Los Santos" +ELYSIAN="Elysian Island" +GALFISH="Galilee" +GALLI="Galileo Park" +GOLF="GWC and Golfing Society" +GRAPES="Grapeseed" +GREATC="Great Chaparral" +HARMO="Harmony" +HAWICK="Hawick" +HEART="Heart Attacks Beach" +HORS="Vinewood Racetrack" +HUD_MG_TRI_ALA="Alamo Sea" +HUD_MG_TRI_VES="Vespucci" +HUMLAB="Humane Labs and Research" +JAIL="Bolingbroke Penitentiary" +KOREAT="Little Seoul" +LACT="Land Act Reservoir" +LAGO="Lago Zancudo" +LDAM="Land Act Dam" +LMESA="La Mesa" +LOSPUER="La Puerta" +LOSSF="Los Santos Freeway" +MGCR_1="South Los Santos" +MGCR_6="Vespucci Canals" +MGSR_3="Raton Canyon" +MIRR="Mirror Park" +MORN="Morningwood" +MOVIE="Richards Majestic" +MTCHIL="Mount Chiliad" +MTGORDO="Mount Gordo" +MTJOSE="Mount Josiah" +MURRI="Murrieta Heights" +NCHU="North Chumash" +OBSERV="Galileo Observatory" +OCEANA="Pacific Ocean" +PALCOV="Paleto Cove" +PALETO="Paleto Bay" +PALFOR="Paleto Forest" +PALHIGH="Palomino Highlands" +PALMPOW="Palmer-Taylor Power Station" +PBLUFF="Pacific Bluffs" +PBOX="Pillbox Hill" +PROCOB="Procopio Beach" +PROL="North Yankton" +RANCHO="Rancho" +RGLEN="Richman Glen" +RICHM="Richman" +ROCKF="Rockford Hills" +RTRAK="Redwood Lights Track" +SANAND="San Andreas" +SANCHIA="San Chianski Mountain Range" +SANDY="Sandy Shores" +SKID="Mission Row" +SLAB="Stab City" +SLSANT="South Los Santos" +STAD="Maze Bank Arena" +STRAW="Strawberry" +TATAMO="Tataviam Mountains" +TERMINA="Terminal" +TEXTI="Textile City" +TONGVAH="Tongva Hills" +TONGVAV="Tongva Valley" +UTOPIAG="Utopia Gardens" +VCANA="Vespucci Canals" +VESP="Vespucci" +VINE="Vinewood" +WINDF="Ron Alternates Wind Farm" +WMIRROR="West Mirror Drive" +WVINE="West Vinewood" +ZANCUDO="Zancudo River" +ZENORA="Senora Freeway" diff --git a/res/global.es.ini b/res/global.es.ini index dda46a7..b2d3cb6 100644 --- a/res/global.es.ini +++ b/res/global.es.ini @@ -1,107 +1,107 @@ -[Global] -AIRP="Aeropuerto Intl. de Los Santos" -ALAMO="Alamo Sea" -ALTA="Alta" -ARMYB="Fort Zancudo" -BANNING="Banning" -BAYTRE="Baytree Canyon" -BEACH="Vespucci Beach" -BHAMCA="Banham Canyon" -BRADP="Braddock Pass" -BRADT="Túnel de Braddock" -BURTON="Burton" -CALAFB="Puente de Calafia" -CANNY="Raton Canyon" -CCREAK="Cassidy Creek" -CHAMH="Chamberlain Hills" -CHIL="Vinewood Hills" -CHU="Chumash" -CMSW="Parque natural del monte Chiliad" -COSI="Zona rural" -CYPRE="Cypress Flats" -DAVIS="Davis" -DELBE="Del Perro Beach" -DELPE="Del Perro" -DELSOL="La Puerta" -DESRT="Desierto de Grand Señora" -DOWNT="Centro" -DTVINE="Centro de Vinewood" -EAST_V="Vinewood Este" -EBURO="El Burro Heights" -ECLIPS="Eclipse" -ELGORL="Faro de El Gordo" -ELSANT="Los Santos Este" -ELYSIAN="Elysian Island" -GALFISH="Galilee" -GALLI="Galileo Park" -GOLF="Club de campo y de golf GW" -GRAPES="Grapeseed" -GREATC="Great Chaparral" -HARMO="Harmony" -HAWICK="Hawick" -HEART="Heart Attacks Beach" -HORS="Circuito de Vinewood" -HUD_MG_TRI_ALA="Alamo Sea" -HUD_MG_TRI_VES="Vespucci" -HUMLAB="Laboratorios Humane" -JAIL="Penitenciaría de Bolingbroke" -KOREAT="Little Seoul" -LACT="Embalse de Land Act" -LAGO="Lago Zancudo" -LDAM="Presa de Land Act" -LMESA="La Mesa" -LOSPFY="Autopista de La Puerta" -LOSPUER="La Puerta" -LOSSF="Autopista de Los Santos" -MGCR_1="Los Santos Sur" -MGCR_6="Canales de Vespucci" -MGSR_3="Raton Canyon" -MIRR="Mirror Park" -MORN="Morningwood" -MOVIE="Richards Majestic" -MO_CS_HIGH="Alta" -MO_HIGH="Alta" -MTCHIL="Monte Chiliad" -MTGORDO="Monte Gordo" -MTJOSE="Monte Josiah" -MURRI="Murrieta Heights" -NCHU="Chumash Norte" -OBSERV="Observatorio Galileo" -OCEANA="Océano Pacífico" -PALCOV="Paleto Cove" -PALETO="Paleto Bay" -PALFOR="Bosque de Paleto" -PALHIGH="Palomino Highlands" -PALMPOW="Central eléctrica Palmer-Taylor" -PBLUFF="Pacific Bluffs" -PBOX="Pillbox Hill" -PROCOB="Procopio Beach" -PROL="North Yankton" -RANCHO="Rancho" -RGLEN="Richman Glen" -RICHM="Richman" -ROCKF="Rockford Hills" -RTRAK="Circuito Redwood Lights" -SANAND="San Andreas" -SANCHIA="Cordillera San Chianski" -SANDY="Sandy Shores" -SENORA="Autopista de Señora" -SKID="Mission Row" -SLAB="Stab City" -SLSANT="Los Santos Sur" -STAD="Maze Bank Arena" -STRAW="Strawberry" -TATAMO="Montañas Tataviam" -TERMINA="Terminal" -TEXTI="Textile City" -TONGVAH="Colinas de Tongva" -TONGVAV="Valle de Tongva" -UTOPIAG="Utopia Gardens" -VCANA="Canales de Vespucci" -VESP="Vespucci" -VINE="Vinewood" -WINDF="Granja eólica de Ron Alternates" -WMIRROR="West Mirror Drive" -WVINE="Vinewood Oeste" -ZANCUDO="Río Zancudo" -ZENORA="Autopista de Señora" +[Global] +AIRP="Aeropuerto Intl. de Los Santos" +ALAMO="Alamo Sea" +ALTA="Alta" +ARMYB="Fort Zancudo" +BANNING="Banning" +BAYTRE="Baytree Canyon" +BEACH="Vespucci Beach" +BHAMCA="Banham Canyon" +BRADP="Braddock Pass" +BRADT="Túnel de Braddock" +BURTON="Burton" +CALAFB="Puente de Calafia" +CANNY="Raton Canyon" +CCREAK="Cassidy Creek" +CHAMH="Chamberlain Hills" +CHIL="Vinewood Hills" +CHU="Chumash" +CMSW="Parque natural del monte Chiliad" +COSI="Zona rural" +CYPRE="Cypress Flats" +DAVIS="Davis" +DELBE="Del Perro Beach" +DELPE="Del Perro" +DELSOL="La Puerta" +DESRT="Desierto de Grand Señora" +DOWNT="Centro" +DTVINE="Centro de Vinewood" +EAST_V="Vinewood Este" +EBURO="El Burro Heights" +ECLIPS="Eclipse" +ELGORL="Faro de El Gordo" +ELSANT="Los Santos Este" +ELYSIAN="Elysian Island" +GALFISH="Galilee" +GALLI="Galileo Park" +GOLF="Club de campo y de golf GW" +GRAPES="Grapeseed" +GREATC="Great Chaparral" +HARMO="Harmony" +HAWICK="Hawick" +HEART="Heart Attacks Beach" +HORS="Circuito de Vinewood" +HUD_MG_TRI_ALA="Alamo Sea" +HUD_MG_TRI_VES="Vespucci" +HUMLAB="Laboratorios Humane" +JAIL="Penitenciaría de Bolingbroke" +KOREAT="Little Seoul" +LACT="Embalse de Land Act" +LAGO="Lago Zancudo" +LDAM="Presa de Land Act" +LMESA="La Mesa" +LOSPFY="Autopista de La Puerta" +LOSPUER="La Puerta" +LOSSF="Autopista de Los Santos" +MGCR_1="Los Santos Sur" +MGCR_6="Canales de Vespucci" +MGSR_3="Raton Canyon" +MIRR="Mirror Park" +MORN="Morningwood" +MOVIE="Richards Majestic" +MO_CS_HIGH="Alta" +MO_HIGH="Alta" +MTCHIL="Monte Chiliad" +MTGORDO="Monte Gordo" +MTJOSE="Monte Josiah" +MURRI="Murrieta Heights" +NCHU="Chumash Norte" +OBSERV="Observatorio Galileo" +OCEANA="Océano Pacífico" +PALCOV="Paleto Cove" +PALETO="Paleto Bay" +PALFOR="Bosque de Paleto" +PALHIGH="Palomino Highlands" +PALMPOW="Central eléctrica Palmer-Taylor" +PBLUFF="Pacific Bluffs" +PBOX="Pillbox Hill" +PROCOB="Procopio Beach" +PROL="North Yankton" +RANCHO="Rancho" +RGLEN="Richman Glen" +RICHM="Richman" +ROCKF="Rockford Hills" +RTRAK="Circuito Redwood Lights" +SANAND="San Andreas" +SANCHIA="Cordillera San Chianski" +SANDY="Sandy Shores" +SENORA="Autopista de Señora" +SKID="Mission Row" +SLAB="Stab City" +SLSANT="Los Santos Sur" +STAD="Maze Bank Arena" +STRAW="Strawberry" +TATAMO="Montañas Tataviam" +TERMINA="Terminal" +TEXTI="Textile City" +TONGVAH="Colinas de Tongva" +TONGVAV="Valle de Tongva" +UTOPIAG="Utopia Gardens" +VCANA="Canales de Vespucci" +VESP="Vespucci" +VINE="Vinewood" +WINDF="Granja eólica de Ron Alternates" +WMIRROR="West Mirror Drive" +WVINE="Vinewood Oeste" +ZANCUDO="Río Zancudo" +ZENORA="Autopista de Señora" diff --git a/res/global.fr.ini b/res/global.fr.ini index 130709f..e2669d1 100644 --- a/res/global.fr.ini +++ b/res/global.fr.ini @@ -1,103 +1,103 @@ -[Global] -AIRP="Aéroport international de LS" -ALAMO="Alamo Sea" -ALTA="Alta" -ARMYB="Fort Zancudo" -BANNING="Banning" -BAYTRE="Baytree Canyon" -BEACH="Vespucci Beach" -BHAMCA="Banham Canyon" -BRADP="Braddock Pass" -BRADT="Braddock Tunnel" -BURTON="Burton" -CALAFB="Calafia Bridge" -CANNY="Raton Canyon" -CCREAK="Cassidy Creek" -CHAMH="Chamberlain Hills" -CHIL="Vinewood Hills" -CHU="Chumash" -CMSW="Parc national du Mont Chiliad" -CYPRE="Cypress Flats" -DAVIS="Davis" -DELBE="Del Perro Beach" -DELPE="Del Perro" -DELSOL="La Puerta" -DESRT="Grand Señora Desert" -DOWNT="Centre-ville" -DTVINE="Centre de Vinewood" -EAST_V="Vinewood East" -EBURO="El Burro Heights" -ECLIPS="Eclipse" -ELGORL="Phare d'El Gordo" -ELSANT="East Los Santos" -ELYSIAN="Elysian Island" -GALFISH="Galilee" -GALLI="Galileo Park" -GOLF="Club de golf et de détente du Grand Ouest" -GRAPES="Grapeseed" -GREATC="Great Chaparral" -HARMO="Harmony" -HAWICK="Hawick" -HEART="Heart Attacks Beach" -HORS="Hippodrome de Vinewood" -HUD_MG_TRI_ALA="Alamo Sea" -HUD_MG_TRI_VES="Vespucci" -HUMLAB="Laboratoires Humane" -JAIL="Pénitencier de Bolingbroke" -KOREAT="Little Seoul" -LACT="Land Act Reservoir" -LAGO="Lago Zancudo" -LDAM="Land Act Dam" -LMESA="La Mesa" -LOSPFY="La Puerta Freeway" -LOSPUER="La Puerta" -LOSSF="Los Santos Freeway" -MGCR_1="South Los Santos" -MGCR_6="Canaux de Vespucci" -MGSR_3="Raton Canyon" -MIRR="Mirror Park" -MORN="Morningwood" -MOVIE="Richards Majestic" -MTCHIL="Mont Chiliad" -MTGORDO="Mont Gordo" -MTJOSE="Mont Josiah" -MURRI="Murrieta Heights" -NCHU="North Chumash" -OBSERV="Observatoire Galileo" -OCEANA="Océan pacifique" -PALCOV="Paleto Cove" -PALETO="Paleto Bay" -PALFOR="Paleto Forest" -PALHIGH="Palomino Highlands" -PALMPOW="Centrale Palmer-Taylor" -PBLUFF="Pacific Bluffs" -PBOX="Pillbox Hill" -PROCOB="Procopio Beach" -PROL="North Yankton" -RANCHO="Rancho" -RGLEN="Richman Glen" -RICHM="Richman" -ROCKF="Rockford Hills" -RTRAK="Circuit Redwood Lights" -SANAND="San Andreas" -SANCHIA="Monts de San Chianski" -SANDY="Sandy Shores" -SKID="Mission Row" -SLAB="Stab City" -SLSANT="South Los Santos" -STAD="Maze Bank Arena" -STRAW="Strawberry" -TATAMO="Monts Tataviam" -TERMINA="Terminal" -TEXTI="Textile City" -TONGVAH="Tongva Hills" -TONGVAV="Tongva Valley" -UTOPIAG="Utopia Gardens" -VCANA="Canaux de Vespucci" -VESP="Vespucci" -VINE="Vinewood" -WINDF="Parc d'éoliennes Ron Alternates" -WMIRROR="Mirror Drive West" -WVINE="Vinewood West" -ZANCUDO="Zancudo River" -ZENORA="Señora Freeway" +[Global] +AIRP="Aéroport international de LS" +ALAMO="Alamo Sea" +ALTA="Alta" +ARMYB="Fort Zancudo" +BANNING="Banning" +BAYTRE="Baytree Canyon" +BEACH="Vespucci Beach" +BHAMCA="Banham Canyon" +BRADP="Braddock Pass" +BRADT="Braddock Tunnel" +BURTON="Burton" +CALAFB="Calafia Bridge" +CANNY="Raton Canyon" +CCREAK="Cassidy Creek" +CHAMH="Chamberlain Hills" +CHIL="Vinewood Hills" +CHU="Chumash" +CMSW="Parc national du Mont Chiliad" +CYPRE="Cypress Flats" +DAVIS="Davis" +DELBE="Del Perro Beach" +DELPE="Del Perro" +DELSOL="La Puerta" +DESRT="Grand Señora Desert" +DOWNT="Centre-ville" +DTVINE="Centre de Vinewood" +EAST_V="Vinewood East" +EBURO="El Burro Heights" +ECLIPS="Eclipse" +ELGORL="Phare d'El Gordo" +ELSANT="East Los Santos" +ELYSIAN="Elysian Island" +GALFISH="Galilee" +GALLI="Galileo Park" +GOLF="Club de golf et de détente du Grand Ouest" +GRAPES="Grapeseed" +GREATC="Great Chaparral" +HARMO="Harmony" +HAWICK="Hawick" +HEART="Heart Attacks Beach" +HORS="Hippodrome de Vinewood" +HUD_MG_TRI_ALA="Alamo Sea" +HUD_MG_TRI_VES="Vespucci" +HUMLAB="Laboratoires Humane" +JAIL="Pénitencier de Bolingbroke" +KOREAT="Little Seoul" +LACT="Land Act Reservoir" +LAGO="Lago Zancudo" +LDAM="Land Act Dam" +LMESA="La Mesa" +LOSPFY="La Puerta Freeway" +LOSPUER="La Puerta" +LOSSF="Los Santos Freeway" +MGCR_1="South Los Santos" +MGCR_6="Canaux de Vespucci" +MGSR_3="Raton Canyon" +MIRR="Mirror Park" +MORN="Morningwood" +MOVIE="Richards Majestic" +MTCHIL="Mont Chiliad" +MTGORDO="Mont Gordo" +MTJOSE="Mont Josiah" +MURRI="Murrieta Heights" +NCHU="North Chumash" +OBSERV="Observatoire Galileo" +OCEANA="Océan pacifique" +PALCOV="Paleto Cove" +PALETO="Paleto Bay" +PALFOR="Paleto Forest" +PALHIGH="Palomino Highlands" +PALMPOW="Centrale Palmer-Taylor" +PBLUFF="Pacific Bluffs" +PBOX="Pillbox Hill" +PROCOB="Procopio Beach" +PROL="North Yankton" +RANCHO="Rancho" +RGLEN="Richman Glen" +RICHM="Richman" +ROCKF="Rockford Hills" +RTRAK="Circuit Redwood Lights" +SANAND="San Andreas" +SANCHIA="Monts de San Chianski" +SANDY="Sandy Shores" +SKID="Mission Row" +SLAB="Stab City" +SLSANT="South Los Santos" +STAD="Maze Bank Arena" +STRAW="Strawberry" +TATAMO="Monts Tataviam" +TERMINA="Terminal" +TEXTI="Textile City" +TONGVAH="Tongva Hills" +TONGVAV="Tongva Valley" +UTOPIAG="Utopia Gardens" +VCANA="Canaux de Vespucci" +VESP="Vespucci" +VINE="Vinewood" +WINDF="Parc d'éoliennes Ron Alternates" +WMIRROR="Mirror Drive West" +WVINE="Vinewood West" +ZANCUDO="Zancudo River" +ZENORA="Señora Freeway" diff --git a/res/global.ja.ini b/res/global.ja.ini index 366e294..24ad7d2 100755 --- a/res/global.ja.ini +++ b/res/global.ja.ini @@ -1,106 +1,106 @@ -[Global] -AIRP="ロスサントス国際空港" -ALAMO="アラモ海" -ALTA="アルタ" -ARMYB="フォート・ザンクード" -BANNING="バニング" -BAYTRE="ベイツリー・キャニオン" -BEACH="ベスプッチ・ビーチ" -BHAMCA="バンナムキャニオン" -BRADP="ブラドック・パス" -BRADT="ブラドック・トンネル" -BSS_BSTR_131="リチャーズ・マジェスティック" -BURTON="バートン" -CALAFB="カラフィア橋" -CANNY="ラトン・キャニオン" -CCREAK="キャシディ・クリーク" -CHAMH="チェンバーレイン・ヒルズ" -CHIL="バインウッド・ヒルズ" -CHU="チュマシュ" -CMSW="チリアド山自然保護区" -COSI="農園地帯" -CYPRE="サイプレス・フラット" -DAVIS="デイビス" -DELBE="デル・ペロ・ビーチ" -DELPE="デル・ペロ" -DELSOL="ラ・プエルタ" -DESRT="グランド・セノーラ砂漠" -DOWNT="ダウンタウン" -DTVINE="ダウンタウン・バインウッド" -EAST_V="イースト・バインウッド" -EBURO="エル・ブロ・ハイツ" -ECLIPS="イクリプス" -ELGORL="エル・ゴルド灯台" -ELSANT="イースト・ロスサントス" -ELYSIAN="エリシアン島" -GALFISH="ガリラヤ" -GALLI="ガリレオ・パーク" -GOLF="GWC&ゴルフ協会" -GRAPES="グレイプシード" -GREATC="グレート・チャパレル" -HARMO="ハーモニー" -HAWICK="ハウィック" -HEART="ハートアタック・ビーチ" -HORS="バインウッド・レーストラック" -HUD_MG_TRI_ALA="アラモ海" -HUD_MG_TRI_VES="ベスプッチ" -HUMLAB="ヒューメイン研究所" -JAIL="ボーリングブローク刑務所" -KOREAT="リトル・ソウル" -LACT="ランド・アクト貯水池" -LAGO="ラゴ・ザンクード" -LDAM="ランド・アクト・ダム" -LMESA="ラ・メサ" -LOSPFY="ラ・プエルタ高速道路" -LOSPUER="ラ・プエルタ" -LOSSF="ロスサントス高速道路" -MGCR_1="サウス・ロスサントス" -MGCR_6="ベスプッチ運河" -MGSR_3="ラトン・キャニオン" -MIRR="ミラー・パーク" -MORN="モーニングウッド" -MOVIE="リチャーズ・マジェスティック" -MTCHIL="チリアド山" -MTGORDO="ゴルド山" -MTJOSE="ジョサイア山" -MURRI="ムリエタ・ハイツ" -NCHU="北チュマシュ" -OBSERV="ガリレオ観測所" -OCEANA="太平洋" -PALCOV="パレト・コーブ" -PALETO="パレト・ベイ" -PALFOR="パレト・フォレスト" -PALHIGH="パロミノ高地" -PALMPOW="パーマー・テイラー発電所" -PBLUFF="パシフィック・ブラフス" -PBOX="ピルボックス・ヒル" -PROCOB="プロコピオ・ビーチ" -PROL="ノース・ヤンクトン" -RANCHO="ランチョ" -RGLEN="リッチマン・グレン" -RICHM="リッチマン" -ROCKF="ロックフォード・ヒルズ" -RTRAK="レッドウッド・ライト・トラック" -SANAND="サンアンドレアス" -SANCHIA="サン・チアンスキー山脈" -SANDY="サンディ海岸" -SENORA="セノーラ高速道路" -SKID="ミッション・ロウ" -SLAB="スタブシティ" -SLSANT="サウス・ロスサントス" -STAD="メイズバンク・アリーナ" -STRAW="ストロベリー" -TATAMO="タタヴィアム山地" -TERMINA="ターミナル" -TEXTI="テキスタイルシティ" -TONGVAH="トングバ・ヒルズ" -TONGVAV="トングバ・バレー" -UTOPIAG="ユートピア・ガーデンズ" -VCANA="ベスプッチ運河" -VESP="ベスプッチ" -VINE="バインウッド" -WINDF="ロン・オルタネット・ウィンドファーム" -WMIRROR="ウエスト・ミラー・ドライブ" -WVINE="ウエスト・バインウッド" -ZANCUDO="ザンクード川" -ZENORA="セノーラ高速道路" +[Global] +AIRP="ロスサントス国際空港" +ALAMO="アラモ海" +ALTA="アルタ" +ARMYB="フォート・ザンクード" +BANNING="バニング" +BAYTRE="ベイツリー・キャニオン" +BEACH="ベスプッチ・ビーチ" +BHAMCA="バンナムキャニオン" +BRADP="ブラドック・パス" +BRADT="ブラドック・トンネル" +BSS_BSTR_131="リチャーズ・マジェスティック" +BURTON="バートン" +CALAFB="カラフィア橋" +CANNY="ラトン・キャニオン" +CCREAK="キャシディ・クリーク" +CHAMH="チェンバーレイン・ヒルズ" +CHIL="バインウッド・ヒルズ" +CHU="チュマシュ" +CMSW="チリアド山自然保護区" +COSI="農園地帯" +CYPRE="サイプレス・フラット" +DAVIS="デイビス" +DELBE="デル・ペロ・ビーチ" +DELPE="デル・ペロ" +DELSOL="ラ・プエルタ" +DESRT="グランド・セノーラ砂漠" +DOWNT="ダウンタウン" +DTVINE="ダウンタウン・バインウッド" +EAST_V="イースト・バインウッド" +EBURO="エル・ブロ・ハイツ" +ECLIPS="イクリプス" +ELGORL="エル・ゴルド灯台" +ELSANT="イースト・ロスサントス" +ELYSIAN="エリシアン島" +GALFISH="ガリラヤ" +GALLI="ガリレオ・パーク" +GOLF="GWC&ゴルフ協会" +GRAPES="グレイプシード" +GREATC="グレート・チャパレル" +HARMO="ハーモニー" +HAWICK="ハウィック" +HEART="ハートアタック・ビーチ" +HORS="バインウッド・レーストラック" +HUD_MG_TRI_ALA="アラモ海" +HUD_MG_TRI_VES="ベスプッチ" +HUMLAB="ヒューメイン研究所" +JAIL="ボーリングブローク刑務所" +KOREAT="リトル・ソウル" +LACT="ランド・アクト貯水池" +LAGO="ラゴ・ザンクード" +LDAM="ランド・アクト・ダム" +LMESA="ラ・メサ" +LOSPFY="ラ・プエルタ高速道路" +LOSPUER="ラ・プエルタ" +LOSSF="ロスサントス高速道路" +MGCR_1="サウス・ロスサントス" +MGCR_6="ベスプッチ運河" +MGSR_3="ラトン・キャニオン" +MIRR="ミラー・パーク" +MORN="モーニングウッド" +MOVIE="リチャーズ・マジェスティック" +MTCHIL="チリアド山" +MTGORDO="ゴルド山" +MTJOSE="ジョサイア山" +MURRI="ムリエタ・ハイツ" +NCHU="北チュマシュ" +OBSERV="ガリレオ観測所" +OCEANA="太平洋" +PALCOV="パレト・コーブ" +PALETO="パレト・ベイ" +PALFOR="パレト・フォレスト" +PALHIGH="パロミノ高地" +PALMPOW="パーマー・テイラー発電所" +PBLUFF="パシフィック・ブラフス" +PBOX="ピルボックス・ヒル" +PROCOB="プロコピオ・ビーチ" +PROL="ノース・ヤンクトン" +RANCHO="ランチョ" +RGLEN="リッチマン・グレン" +RICHM="リッチマン" +ROCKF="ロックフォード・ヒルズ" +RTRAK="レッドウッド・ライト・トラック" +SANAND="サンアンドレアス" +SANCHIA="サン・チアンスキー山脈" +SANDY="サンディ海岸" +SENORA="セノーラ高速道路" +SKID="ミッション・ロウ" +SLAB="スタブシティ" +SLSANT="サウス・ロスサントス" +STAD="メイズバンク・アリーナ" +STRAW="ストロベリー" +TATAMO="タタヴィアム山地" +TERMINA="ターミナル" +TEXTI="テキスタイルシティ" +TONGVAH="トングバ・ヒルズ" +TONGVAV="トングバ・バレー" +UTOPIAG="ユートピア・ガーデンズ" +VCANA="ベスプッチ運河" +VESP="ベスプッチ" +VINE="バインウッド" +WINDF="ロン・オルタネット・ウィンドファーム" +WMIRROR="ウエスト・ミラー・ドライブ" +WVINE="ウエスト・バインウッド" +ZANCUDO="ザンクード川" +ZENORA="セノーラ高速道路" diff --git a/res/global.zh.ini b/res/global.zh.ini index 35564bd..3990a2f 100644 --- a/res/global.zh.ini +++ b/res/global.zh.ini @@ -1,104 +1,104 @@ -[Global] -AIRP="洛聖都國際機場" -ALAMO="阿拉莫海" -ALTA="艾爾塔" -ARMYB="桑庫多堡壘" -BANNING="班寧" -BAYTRE="貝特里峽谷" -BEACH="威斯普奇海灘" -BHAMCA="班漢峽谷" -BRADP="布萊杜要道" -BRADT="布萊杜隧道" -BURTON="巴頓" -CALAFB="卡拉非橋" -CANNY="雷通峽谷" -CCREAK="加斯迪小溪" -CHAMH="張伯倫山" -CHIL="好麥塢山" -CHU="丘瑪墟" -CMSW="奇力耶德山國家生態保護區" -CYPRE="扁柏平地" -DAVIS="戴維斯" -DELBE="佩羅海灘" -DELPE="佩羅" -DELSOL="洛波塔" -DESRT="塞諾拉大沙漠" -DOWNT="市中心" -DTVINE="好麥塢市中心" -EAST_V="東好麥塢" -EBURO="布羅高地" -ECLIPS="日蝕" -ELGORL="戈多燈塔" -ELSANT="東洛聖都" -ELYSIAN="安樂島" -GALFISH="加利利" -GALLI="伽利略公園" -GOLF="西部鄉村高爾夫俱樂部" -GRAPES="葡萄籽" -GREATC="大叢林" -HARMO="和美尼" -HAWICK="霍伊克" -HEART="驚心海灘" -HORS="好麥塢賽馬場" -HUD_MG_TRI_ALA="阿拉莫海" -HUD_MG_TRI_VES="威斯普奇" -HUMLAB="人道研究實驗室" -JAIL="博林布魯克監獄" -KOREAT="小首爾" -LACT="蘭艾水庫" -LAGO="桑庫多沼地" -LDAM="蘭艾水壩" -LMESA="梅薩" -LOSPFY="洛波塔高速公路" -LOSPUER="洛波塔" -LOSSF="洛聖都高速公路" -MGCR_1="南洛聖都" -MGCR_6="威斯普奇運河" -MGSR_3="雷通峽谷" -MIRR="米羅公園" -MORN="摩寧塢" -MOVIE="李察尊爵" -MTCHIL="奇力耶德山" -MTGORDO="戈多山" -MTJOSE="尤夏山" -MURRI="穆瑞塔高地" -NCHU="北丘瑪墟" -OBSERV="伽利略天文台" -OCEANA="太平洋" -PALCOV="佩立托小海灣" -PALETO="佩立托灣" -PALFOR="佩立托森林" -PALHIGH="巴洛米諾高地" -PALMPOW="帕莫泰勒發電站" -PBLUFF="太平崖" -PBOX="圓帽山" -PROCOB="普羅科皮奧海灘" -PROL="北揚克頓" -RANCHO="藍丘" -RGLEN="利金漫幽谷" -RICHM="利金漫" -ROCKF="羅克福德山" -RTRAK="紅木賽道" -SANAND="聖安地列斯" -SANCHIA="聖強斯基山脈" -SANDY="沙灘海岸" -SENORA="塞諾拉高速公路" -SKID="密申羅" -SLAB="背刺城" -SLSANT="南洛聖都" -STAD="花園銀行體育場" -STRAW="斯卓貝利" -TATAMO="塔塔維昂山" -TERMINA="碼頭" -TEXTI="紡織城" -TONGVAH="通瓦山" -TONGVAV="通瓦谷地" -UTOPIAG="烏托邦花園" -VCANA="威斯普奇運河" -VESP="威斯普奇" -VINE="好麥塢" -WINDF="朗恩.艾特梅茲風車農場" -WMIRROR="米羅車道西段" -WVINE="西好麥塢" -ZANCUDO="桑庫多河" -ZENORA="塞諾拉高速公路" +[Global] +AIRP="洛聖都國際機場" +ALAMO="阿拉莫海" +ALTA="艾爾塔" +ARMYB="桑庫多堡壘" +BANNING="班寧" +BAYTRE="貝特里峽谷" +BEACH="威斯普奇海灘" +BHAMCA="班漢峽谷" +BRADP="布萊杜要道" +BRADT="布萊杜隧道" +BURTON="巴頓" +CALAFB="卡拉非橋" +CANNY="雷通峽谷" +CCREAK="加斯迪小溪" +CHAMH="張伯倫山" +CHIL="好麥塢山" +CHU="丘瑪墟" +CMSW="奇力耶德山國家生態保護區" +CYPRE="扁柏平地" +DAVIS="戴維斯" +DELBE="佩羅海灘" +DELPE="佩羅" +DELSOL="洛波塔" +DESRT="塞諾拉大沙漠" +DOWNT="市中心" +DTVINE="好麥塢市中心" +EAST_V="東好麥塢" +EBURO="布羅高地" +ECLIPS="日蝕" +ELGORL="戈多燈塔" +ELSANT="東洛聖都" +ELYSIAN="安樂島" +GALFISH="加利利" +GALLI="伽利略公園" +GOLF="西部鄉村高爾夫俱樂部" +GRAPES="葡萄籽" +GREATC="大叢林" +HARMO="和美尼" +HAWICK="霍伊克" +HEART="驚心海灘" +HORS="好麥塢賽馬場" +HUD_MG_TRI_ALA="阿拉莫海" +HUD_MG_TRI_VES="威斯普奇" +HUMLAB="人道研究實驗室" +JAIL="博林布魯克監獄" +KOREAT="小首爾" +LACT="蘭艾水庫" +LAGO="桑庫多沼地" +LDAM="蘭艾水壩" +LMESA="梅薩" +LOSPFY="洛波塔高速公路" +LOSPUER="洛波塔" +LOSSF="洛聖都高速公路" +MGCR_1="南洛聖都" +MGCR_6="威斯普奇運河" +MGSR_3="雷通峽谷" +MIRR="米羅公園" +MORN="摩寧塢" +MOVIE="李察尊爵" +MTCHIL="奇力耶德山" +MTGORDO="戈多山" +MTJOSE="尤夏山" +MURRI="穆瑞塔高地" +NCHU="北丘瑪墟" +OBSERV="伽利略天文台" +OCEANA="太平洋" +PALCOV="佩立托小海灣" +PALETO="佩立托灣" +PALFOR="佩立托森林" +PALHIGH="巴洛米諾高地" +PALMPOW="帕莫泰勒發電站" +PBLUFF="太平崖" +PBOX="圓帽山" +PROCOB="普羅科皮奧海灘" +PROL="北揚克頓" +RANCHO="藍丘" +RGLEN="利金漫幽谷" +RICHM="利金漫" +ROCKF="羅克福德山" +RTRAK="紅木賽道" +SANAND="聖安地列斯" +SANCHIA="聖強斯基山脈" +SANDY="沙灘海岸" +SENORA="塞諾拉高速公路" +SKID="密申羅" +SLAB="背刺城" +SLSANT="南洛聖都" +STAD="花園銀行體育場" +STRAW="斯卓貝利" +TATAMO="塔塔維昂山" +TERMINA="碼頭" +TEXTI="紡織城" +TONGVAH="通瓦山" +TONGVAV="通瓦谷地" +UTOPIAG="烏托邦花園" +VCANA="威斯普奇運河" +VESP="威斯普奇" +VINE="好麥塢" +WINDF="朗恩.艾特梅茲風車農場" +WMIRROR="米羅車道西段" +WVINE="西好麥塢" +ZANCUDO="桑庫多河" +ZENORA="塞諾拉高速公路" diff --git a/res/gta5sync_de.qm b/res/gta5sync_de.qm index b174c2b03ec3eb675e1a5147f35472b101f13f59..2a5912fd63d9f38424830bb93e934688826469a4 100755 GIT binary patch delta 1491 zcmYk6eN0nl6vm&n_qM&ge5incfEEw~1rZq_A}~OKic+0|6eu4BE?A^UuukV6s}7h; z<}~Jxu`C$IhQy7Txiv;N1O}5Vnqi$E>_go$15qX$!OXFdZ0yv#bxZT+m-pUtp7)&h zIk(gIWv@Pv`K4a03Aj4b**+E;JXF~|a4!o`2b}Z^Q?lED9omzLp>|Y!4(z%OruPM) zgay;j0NcC3IEi%^z>F6FSsd8ZMBuqxuzKQR2iS8P0ly@$&MyGNki?2zP*mI zw}9#j?hleg$C7lw!Lu)xj) z%r+XRtUQ_KZVa&L8;M1SC005_L6)v5Nt0XK3V@n2@vO`suRI|BDO(j*_elQ3l`Vj; zQ+~hK7pRacxZc}9*_(>Q{ZD9rOw5+=vI~2dzT>|FLKl%9*LoA@h<4&1LkqO^&vXD0dUmz-MIfY0qDjS;TpIzl ze!^Pct_Ie$vYjzhe_;mOJzoGkqhouH6q5tz*>mp?ko9v)cAW!IJXD5^dXbej@x0>Y zB~{a^p5aC^^pxtOEx!OoPBEWZ9#(!<9WojV#F^EZ^F7qf8|tjb-9RO)-g?Ff6eo+X zF@g5Oq2JOl9#s#H+@Oe0*8acrA^)$Eom=&L zIAHpci#jNf_V*GOX}R2v<5Wr-SEiy$eSYSuI_T!|4{;6pSvotFYp5kEH*?K%@iYya z#1Pg?XFA073>$#mZQPX%JCHNNjmNG7f)==$aVovOjYtO7kBEhA(z5b$&4$`e3ja!z zKSdLqe@#;~;{{k+#M5lLynaEPWMehPbj|pRLi)gl#1Lh=y?P~oEN7C&e78j75&rmJ z!89~C`4gC+;n>Kx`;)l^b$n-ZE5-FnG=9bpT1V;ZL?Y!|Ci%aLlU$wkHK66OE{Y04uG1^b=^G0xcr2R!tuOl(f7vo0^*UHZ@z!HX%hD zu~zIh28v6Jso}oJq69OVQAM=C=1O;`G1)a1+tXNs@kc%e270@nRw6}wp^Tz^9ywgy5+q8 zlPVx7@wzcs95dx52E!fuZ?DvGB=sDRD0jA(E9Ysy+Q^9bDA#d|805k1j!+bf=S)Ek J|FS~gzX6Q?nDPJs delta 1078 zcmXAoe^Aq99LL|=zF+qJ?mLDaaKnH><0Kr2KSD5tNn8Wv#}Z{5n+zOtfYso-vaGIl zCistuanF(IO>;H53hxZKI%6kB$g;xWB|@=g*fsZux(7SX4hS+PcWz4`i#4u8y)-;a8D9x zc}EfP9`Rk`Kg9FIhxBsbMh}8mMwAhIhzg>gJ6Uo9sQV_#*5ll%y*5DT<3ds=S=r1@ zzgI?FV7UsN%I@M~lY6P$$4rVsxqCJ9Ds(lDeBLn|0UAH&y~o|aihkZ-LSkA9_`rQ~ z_PBu$?y=KD&hnppJOyOlOW`Xf0L6`z+^B{EIlyKV`+P2584UMQE}tpK8h!&THBfOX?SU)TfGX9?30ifQXjA$o>9mJSGs&@i?lb)Bd^9j3-hMD68jYM>IA zIzIx|`^3V(3joJ;aoKLVK=>)iMfqagp+ORC6`e}*lYU$5JVb(eB>Fzm3qzrm~WV`tCN7`Oit?%;F_M57vc^c2A zS(PoJ0lNJx${Xc7vlyRJsrC}*U< zLO;;Iyp*ISRm~kSk;rXo@zz}^P?pblWx3wsPzTefPj$Nbi^K~w)GO2>8BuCW&7P+W zTDqA>xktOPmhR5gr~OZRAgwn(4m7V~yihFP`79gLET8BQZavKow^p*n_FpFY9exFS MzP)jxyu*_5FT^-P;{X5v diff --git a/res/gta5sync_de.ts b/res/gta5sync_de.ts index 8dd0709..5210bf9 100755 --- a/res/gta5sync_de.ts +++ b/res/gta5sync_de.ts @@ -196,32 +196,32 @@ Grand Theft Auto V Snapmatic Bilder und Spielständen Importieren... - + Settings Einstellungen - + &Keep Aspect Ratio Seitenverhältnis &behalten - + &Ignore Aspect Ratio Seitenverhältnis &ignorieren - + &Avatar &Avatar - + &OK &OK - + &Cancel Abbre&chen @@ -559,17 +559,17 @@ Grand Theft Auto V Snapmatic Bilder und Spielständen Schließen - + Export as &JPG picture... Exportiere als &JPG Bild... - + Export as &GTA Snapmatic... Exportiere als &GTA Snapmatic... - + Key 1 - Avatar Preview Mode Key 2 - Toggle Overlay Arrow Keys - Navigate @@ -578,19 +578,19 @@ Taste 2 - Overlay umschalten Pfeiltasten - Navigieren - - + + Snapmatic Picture Viewer Snapmatic Bildansicht - - + + Failed at %1 Fehlgeschlagen bei %1 - + Avatar Preview Mode Press 1 for Default View Avatar Vorschaumodus @@ -627,19 +627,19 @@ Drücke A für Standardansicht Avatar Vorschaumodus<br>Drücke A für Standardansicht - - + + No player Keine Spieler - - + + No crew Keine Crew - + Unknown Location Unbekannter Standort @@ -864,13 +864,13 @@ Drücke A für Standardansicht - + Savegames files (SGTA*) Spielstanddateien (SGTA*) - + Snapmatic pictures (PGTA*) Snapmatic Bilder (PGTA*) @@ -881,7 +881,7 @@ Drücke A für Standardansicht - + All files (**) Alle Dateien (**) @@ -902,13 +902,13 @@ Drücke A für Standardansicht - + Failed to read Snapmatic picture Fehler beim Lesen vom Snapmatic Bild - + Failed to read Savegame file Fehler beim Lesen von Spielstanddatei @@ -935,7 +935,7 @@ Drücke A für Standardansicht - + No valid file is selected Keine gültige Datei wurde ausgewählt @@ -1096,20 +1096,20 @@ Exportieren als: Aktueller Exportiervorgang: %1 - - - + + + Export file %1 of %2 files Exportiere Datei %1 von %2 Dateien - + All profile files (*.g5e SGTA* PGTA*) Alle Profildateien (*.g5e SGTA* PGTA*) - + GTA V Export (*.g5e) GTA V Export (*.g5e) @@ -1211,13 +1211,13 @@ Exportieren als: - - + + Delete savegame Savegame löschen - + Export Savegame... Spielstand exportieren... @@ -1227,8 +1227,8 @@ Exportieren als: SPIELSTAND %3 - %1<br>%2 + - WRONG FORMAT FALSCHES FORMAT @@ -1237,63 +1237,63 @@ Exportieren als: AUTO - + AUTOSAVE - %1 %2 AUTOSAVE - %1 %2 - + SAVE %3 - %1 %2 SPIELSTAND %3 - %1 %2 - + UNKNOWN UNKNOWN - + Are you sure to delete %1 from your savegames? Bist du sicher %1 von deinen Spielständen zu löschen? - + Failed at deleting %1 from your savegames Fehlgeschlagen beim Löschen %1 von deinen Spielständen - + &View A&nsehen - + &Remove Entfe&rnen - - + + &Select Au&swählen - + &Deselect A&bwählen - - + + Select &All &Alles auswählen - + &Deselect All Alles a&bwählen @@ -1332,7 +1332,7 @@ Exportieren als: Spielstand kopieren - + &Export &Exportieren @@ -1408,7 +1408,7 @@ Exportieren als: - + Snapmatic Properties Snapmatic Eigenschaften @@ -1456,26 +1456,45 @@ Exportieren als: + + Snapmatic Title + Snapmatic Titel + + + + + Title: %1 (%2) + Titel: %1 (%2) + + + + + + Appropriate: %1 + Angemessen: %1 + + + Extras Extras - + Qualify as Avatar automatically at apply Beim Übernehmen als Avatar qualifizieren - + Qualify as Avatar allows you to use this Snapmatic as a Social Club profile picture Das Qualifizieren als Avatar erlaubt dir dieses Snapmatic als Social Club Profilbild zu nutzen - + &Apply &Übernehmen - + &Cancel Abbre&chen @@ -1488,15 +1507,37 @@ Exportieren als: Cancel - + + Edit + Bearbeiten + + + + Yes + Yes, should work fine + Ja + + + + No + No, could lead to issues + Nein + + + Patching of Snapmatic Properties failed because of I/O Error Patchen von Snapmatic Eigenschaften fehlgeschlagen wegen I/O Fehler + + + New Snapmatic title: + Neuer Snapmatic Titel: + SnapmaticPicture - + PHOTO - %1 FOTO - %1 @@ -1535,18 +1576,18 @@ Exportieren als: - - + + Delete picture Bild löschen - + Are you sure to delete %1 from your Snapmatic pictures? Bist du sicher %1 von deinen Snapmatic Bilder zu löschen? - + Edi&t Bearbei&ten @@ -1559,7 +1600,7 @@ Exportieren als: &Im Spiel deaktivieren - + &Export &Exportieren @@ -1572,12 +1613,12 @@ Exportieren als: Exportiere als &GTA Snapmatic - + Show &In-game &Im Spiel anzeigen - + Hide &In-game &Im Spiel ausblenden @@ -1590,49 +1631,49 @@ Exportieren als: FOTO - %1 - + &Edit Properties... &Eigenschaften bearbeiten... - + Export as &JPG picture... Exportiere als &JPG Bild... - + Export as &GTA Snapmatic... Exportiere als &GTA Snapmatic... - + &View A&nsehen - + &Remove Entfe&rnen - - + + &Select Au&swählen - + &Deselect A&bwählen - - + + Select &All Alles &auswählen - + &Deselect All Alles a&bwählen @@ -1680,7 +1721,7 @@ Exportieren als: Bist du sicher %1 von deinen Snapmatic Bilder zu löschen? - + Failed at deleting %1 from your Snapmatic pictures Fehlgeschlagen beim Löschen %1 von deinen Snapmatic Bildern @@ -1720,7 +1761,7 @@ Exportieren als: Über gta5sync - + Ctrl+A Strg+A @@ -1733,7 +1774,7 @@ Exportieren als: Optionen - + Ctrl+O Strg+O @@ -1742,7 +1783,7 @@ Exportieren als: Alles auswählen - + Ctrl+S Strg+S @@ -1759,7 +1800,7 @@ Exportieren als: Auswahl exportieren - + Ctrl+E Strg+E @@ -1768,12 +1809,12 @@ Exportieren als: Auswahl löschen - + Ctrl+D Strg+D - + Exit Beenden @@ -1787,12 +1828,12 @@ Exportieren als: &Über Produkt - + &Exit B&eenden - + Ctrl+Q Strg+Q @@ -1835,43 +1876,43 @@ Exportieren als: &Über gta5sync - + Close &Profile &Profil schließen - + Ctrl+End Strg+Ende - + Ctrl+Del Strg+Entf - + &Open File... Datei &öffnen... - - + + Select &GTA V Folder... Wähle &GTA V Ordner... - + Ctrl+G Strg+G - + Show In-gam&e Im Spiel anzeig&en - + Hi&de In-game Im Spiel ausblen&den @@ -1884,7 +1925,7 @@ Exportieren als: Im Spiel aktivier&en - + Shift+E Umschalt+E @@ -1893,7 +1934,7 @@ Exportieren als: Im Spiel &deaktivieren - + Shift+D Umschalt+D @@ -1916,27 +1957,27 @@ Exportieren als: &Optionen - + &Settings Ein&stellungen - + Select &All &Alles auswählen - + &Deselect All Alles a&bwählen - + &Export selected... Auswahl &exportieren... - + &Remove selected Auswahl entfe&rnen @@ -1945,12 +1986,12 @@ Exportieren als: Strg+R - + &Import files... Dateien &importieren... - + Ctrl+I Strg+I @@ -1959,16 +2000,16 @@ Exportieren als: GTA V Ordner nicht gefunden! - - + + Select Profile Profil auswählen - + - - + + Select GTA V Folder... Wähle GTA V Ordner... @@ -1977,7 +2018,7 @@ Exportieren als: Wähle GTA V &Ordner... - + Open File... Datei öffnen... @@ -1987,26 +2028,26 @@ Exportieren als: - + %2 - %1 %2 - %1 - + &About %1 &Über %1 - - - - + + + + Open File Datei öffnen - + Can't open %1 because of not valid file format Kann nicht %1 öffnen weil Dateiformat nicht gültig ist diff --git a/res/gta5sync_fr.ts b/res/gta5sync_fr.ts index 062d411..bf2ffa2 100644 --- a/res/gta5sync_fr.ts +++ b/res/gta5sync_fr.ts @@ -1,11 +1,11 @@ - + AboutDialog About gta5sync - À propos de gta5sync + À propos de gta5sync <span style=" font-weight:600;">gta5sync</span><br/> @@ -19,7 +19,7 @@ Compiled with Qt %2<br/> Running with Qt %3<br/> <br/> Copyright &copy; <a href="https://github.com/Syping/">Syping</a> 2016<br/>gta5sync is licensed under <a href="https://www.gnu.org/licenses/gpl-3.0.html#content">GNU GPLv3</a> - <span style=" font-weight:600;">gta5sync</span><br/> + <span style=" font-weight:600;">gta5sync</span><br/> <br/> Un outil pour gérer et synchroniser les photos Snapmatic<br/> et les fichiers de sauvegarde de Grand Theft Auto V<br/> @@ -152,32 +152,32 @@ et les fichiers de sauvegarde de Grand Theft Auto V Importer... - + Settings Paramètres - + &Keep Aspect Ratio &Conserver le rapport d'aspect - + &Ignore Aspect Ratio &Ignorer le rapport d'aspect - + &Avatar &Avatar - + &OK &OK - + &Cancel A&nnuler @@ -452,7 +452,7 @@ et les fichiers de sauvegarde de Grand Theft Auto V All files (**) - Tous les fichiers (**) + Tous les fichiers (**) @@ -478,7 +478,7 @@ et les fichiers de sauvegarde de Grand Theft Auto V Failed to copy current Snapmatic picture - Echec de la copie + Echec de la copie @@ -487,17 +487,17 @@ et les fichiers de sauvegarde de Grand Theft Auto V Fichier invalide - + Export as &JPG picture... Exporter comme image &JPG... - + Export as &GTA Snapmatic... Exporter comme &GTA Snapmatic... - + Key 1 - Avatar Preview Mode Key 2 - Toggle Overlay Arrow Keys - Navigate @@ -506,19 +506,19 @@ Touche 2 - Activer/désactiver l'overlay Touches fléchées - Naviguer - - + + Snapmatic Picture Viewer Visionneuse de photo Snapmatic - - + + Failed at %1 Echec de %1 - + Avatar Preview Mode Press 1 for Default View Mode Aperçu Avatar @@ -526,22 +526,22 @@ Appuyer sur 1 pour le mode par défaut Avatar Preview Mode<br>Press A for Default View - Aperçu avatar<br>Appuyer sur A pour la vue par défaut + Aperçu avatar<br>Appuyer sur A pour la vue par défaut - - + + No player Aucun joueur - - + + No crew Aucun crew - + Unknown Location Emplacement inconnu @@ -619,9 +619,9 @@ Appuyer sur 1 pour le mode par défaut &Fermer - - - + + + Export file %1 of %2 files Copie du fichier %1 sur %2 @@ -659,23 +659,23 @@ Appuyer sur 1 pour le mode par défaut All profile files (SGTA* PGTA*) - Fichiers de profil GTA (SGTA* PGTA*) + Fichiers de profil GTA (SGTA* PGTA*) - + Savegames files (SGTA*) Fichiers de sauvegarde GTA (SGTA*) - + Snapmatic pictures (PGTA*) Photos Snapmatic (PGTA*) - + All files (**) Tous les fichiers (**) @@ -697,19 +697,19 @@ Appuyer sur 1 pour le mode par défaut - + No valid file is selected Fichier invalide - + Failed to read Snapmatic picture Impossible d'ouvrir la photo Snapmatic - + Failed to read Savegame file Impossible de lire le fichier de sauvegarde @@ -720,7 +720,7 @@ Appuyer sur 1 pour le mode par défaut Failed to import the Snapmatic picture, file not begin with PGTA - Impossible d'importer la photo Snapmatic,nom de fichier incorrect (PGTA*) + Impossible d'importer la photo Snapmatic,nom de fichier incorrect (PGTA*) @@ -831,13 +831,13 @@ Appuyer sur 1 pour le mode par défaut Impossible de supprimer la sélection - + All profile files (*.g5e SGTA* PGTA*) Tous les fichiers de profil (*.g5e SGTA* PGTA*) - + GTA V Export (*.g5e) GTA V Export (*.g5e) @@ -919,8 +919,8 @@ Appuyer sur 1 pour le mode par défaut - - + + Delete savegame Supprimer la sauvegarde @@ -930,7 +930,7 @@ Appuyer sur 1 pour le mode par défaut Supprimer - + &Export &Exporter @@ -973,74 +973,74 @@ Appuyer sur 1 pour le mode par défaut Fichier invalide - + Export Savegame... Exporter la sauvegarde... - + AUTOSAVE - %1 %2 SAUVEGARDE AUTO - %1 %2 - + SAVE %3 - %1 %2 SAUVEGARDE %3 - %1 %2 + - WRONG FORMAT Format invalide - + UNKNOWN Inconnu - + Are you sure to delete %1 from your savegames? Supprimer %1 ? - + Failed at deleting %1 from your savegames Impossible de supprimer %1 - + &View &Voir - + &Remove &Supprimer - - + + &Select &Sélectionner - + &Deselect &Déselectionner - - + + Select &All Sélectionner to&ut - + &Deselect All &Déselectionner tout @@ -1050,7 +1050,7 @@ Appuyer sur 1 pour le mode par défaut - + Snapmatic Properties Propriétés Snapmatic @@ -1084,7 +1084,7 @@ Appuyer sur 1 pour le mode par défaut Custom - Personnalisé + Personnalisé @@ -1098,39 +1098,80 @@ Appuyer sur 1 pour le mode par défaut + + Snapmatic Title + + + + + + Title: %1 (%2) + + + + + + + Appropriate: %1 + + + + Extras Extras - + Qualify as Avatar automatically at apply Qualifier comme Avatar - + Qualify as Avatar allows you to use this Snapmatic as a Social Club profile picture Qualifier comme Avatar permet d'utiliser cette image en tant que photo de profil sur le Social Club - + &Apply A&ppliquer - + &Cancel A&nnuler - + + Edit + + + + + Yes + Yes, should work fine + + + + + No + No, could lead to issues + + + + Patching of Snapmatic Properties failed because of I/O Error La modification des propriétés Snapmatic a échoué : erreur d'entrée/sortie + + + New Snapmatic title: + + SnapmaticPicture - + PHOTO - %1 PHOTO - %1 @@ -1179,8 +1220,8 @@ Appuyer sur 1 pour le mode par défaut - - + + Delete picture Supprimer la photo @@ -1190,79 +1231,79 @@ Appuyer sur 1 pour le mode par défaut Supprimer - + Are you sure to delete %1 from your Snapmatic pictures? Supprimer %1 ? - + Failed at deleting %1 from your Snapmatic pictures Impossible de supprimer %1 - + Edi&t Édi&ter - + Show &In-game &Visible en jeu - + Hide &In-game &Invisible en jeu - + &Edit Properties... Modifier les &propriétés... - + &Export &Exporter - + Export as &JPG picture... Exporter comme image &JPG... - + Export as &GTA Snapmatic... Exporter comme &GTA Snapmatic... - + &View &Voir - + &Remove S&upprimer - - + + &Select &Sélectionner - + &Deselect &Déselectionner - - + + Select &All Sélectionner &tout - + &Deselect All &Déselectionner tout @@ -1271,7 +1312,7 @@ Appuyer sur 1 pour le mode par défaut UserInterface gta5sync - %1 - gta5sync - %1 + gta5sync - %1 @@ -1315,7 +1356,7 @@ Appuyer sur 1 pour le mode par défaut &About gta5sync - &À propos de gta5sync + &À propos de gta5sync @@ -1323,126 +1364,126 @@ Appuyer sur 1 pour le mode par défaut Ctrl+P - + &Exit &Quitter - + Exit Quitter - + Ctrl+Q Ctrl+Q - + Close &Profile Fermer le &profil - + Ctrl+End Ctrl + Fin - + &Settings Paramètre&s - + Ctrl+S Ctrl+S - + Select &All Sélectionner &tout - + Ctrl+A Ctrl+A - + &Deselect All &Désélectionner tout - + Ctrl+D Ctrl+D - + &Export selected... &Exporter la sélection... - + Ctrl+E Ctrl+E - + &Remove selected &Supprimer la sélection - + Ctrl+Del Ctrl+Del - + &Import files... &Importer... - + Ctrl+I Ctrl+I - + &Open File... &Ouvrir... - + Ctrl+O Ctrl+O - - + + Select &GTA V Folder... Modifier l'emplacement de &GTA V... - + - - + + Select GTA V Folder... Modifier l'emplacement de GTA V... - + Ctrl+G Ctrl+G - + Show In-gam&e Rendre visible &en jeu - + Shift+E Shift+E @@ -1452,48 +1493,48 @@ Appuyer sur 1 pour le mode par défaut &Visibilité de la sélection - + Hi&de In-game Ren&dre invisible en jeu - + Shift+D Shift+D - + %2 - %1 %2 - %1 - + &About %1 &À propos de %1 - - + + Select Profile Sélectionner un profil - + Open File... Ouvrir... - - - - + + + + Open File Ouvrir - + Can't open %1 because of not valid file format Impossible d'ouvrir %1, format invalide diff --git a/uimod/UiModLabel.cpp b/uimod/UiModLabel.cpp index f069fa5..0051a7a 100755 --- a/uimod/UiModLabel.cpp +++ b/uimod/UiModLabel.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping +* Copyright (C) 2016-2017 Syping * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +17,7 @@ *****************************************************************************/ #include "UiModLabel.h" +#include #include UiModLabel::UiModLabel(const QString &text, QWidget *parent) : QLabel(parent) @@ -37,6 +38,12 @@ UiModLabel::~UiModLabel() { } +void UiModLabel::paintEvent(QPaintEvent *ev) +{ + QLabel::paintEvent(ev); + emit labelPainted(); +} + void UiModLabel::mouseMoveEvent(QMouseEvent *ev) { QLabel::mouseMoveEvent(ev); diff --git a/uimod/UiModLabel.h b/uimod/UiModLabel.h index 8d63f9d..545ee27 100755 --- a/uimod/UiModLabel.h +++ b/uimod/UiModLabel.h @@ -1,6 +1,6 @@ /***************************************************************************** * gta5sync GRAND THEFT AUTO V SYNC -* Copyright (C) 2016 Syping +* Copyright (C) 2016-2017 Syping * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +38,7 @@ protected: void mousePressEvent(QMouseEvent *ev); void mouseReleaseEvent(QMouseEvent *ev); void mouseDoubleClickEvent(QMouseEvent *ev); + void paintEvent(QPaintEvent *ev); void resizeEvent(QResizeEvent *ev); signals: @@ -45,6 +46,7 @@ signals: void mousePressed(Qt::MouseButton button); void mouseReleased(Qt::MouseButton button); void mouseDoubleClicked(Qt::MouseButton button); + void labelPainted(); void resized(QSize newSize); };