Browse Source

thread-safe database classes, created instead of last modifed date in

title
1.3.x
Rafael 6 years ago
parent
commit
1067fcf353
  1. 4
      CrewDatabase.cpp
  2. 3
      CrewDatabase.h
  3. 2
      PictureDialog.cpp
  4. 6
      ProfileDatabase.cpp
  5. 1
      ProfileDatabase.h
  6. 4
      SnapmaticPicture.cpp
  7. 1
      SnapmaticPicture.h
  8. 9
      main.cpp

4
CrewDatabase.cpp

@ -47,10 +47,14 @@ CrewDatabase::~CrewDatabase()
QStringList CrewDatabase::getCrews()
{
mutex.lock();
return crewDB->childKeys();
mutex.unlock();
}
void CrewDatabase::addCrew(int crewID)
{
mutex.lock();
crewDB->setValue(QString::number(crewID), crewID);
mutex.unlock();
}

3
CrewDatabase.h

@ -19,8 +19,10 @@
#ifndef CREWDATABASE_H
#define CREWDATABASE_H
#include <QMutexLocker>
#include <QSettings>
#include <QObject>
#include <QMutex>
#include <QMap>
class CrewDatabase : public QObject
@ -32,6 +34,7 @@ public:
~CrewDatabase();
private:
QMutex mutex;
QSettings *crewDB;
public slots:

2
PictureDialog.cpp

@ -214,7 +214,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu
if (crewID == "") { crewID = tr("No crew"); }
this->setWindowTitle(windowTitleStr.arg(picture->getPictureStr()));
this->setWindowTitle(windowTitleStr.arg(picture->getCreatedDateTime().toString(Qt::DefaultLocaleLongDate)));
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID, picTitl, picAreaStr));
}
else

6
ProfileDatabase.cpp

@ -47,15 +47,21 @@ ProfileDatabase::~ProfileDatabase()
QStringList ProfileDatabase::getPlayers()
{
mutex.lock();
return profileDB->childKeys();
mutex.unlock();
}
QString ProfileDatabase::getPlayerName(int playerID)
{
mutex.lock();
return profileDB->value(QString::number(playerID), playerID).toString();
mutex.unlock();
}
void ProfileDatabase::setPlayerName(int playerID, QString playerName)
{
mutex.lock();
profileDB->setValue(QString::number(playerID), playerName);
mutex.unlock();
}

1
ProfileDatabase.h

@ -33,6 +33,7 @@ public:
~ProfileDatabase();
private:
QMutex mutex;
QSettings *profileDB;
public slots:

4
SnapmaticPicture.cpp

@ -56,6 +56,7 @@ SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : Q
jsonLocZ = 0;
jsonCrewID = 0;
jsonArea = "";
jsonCreatedTimestamp = 0;
jsonPlyrsList = QStringList();
}
@ -345,7 +346,8 @@ void SnapmaticPicture::parseJsonContent()
if (jsonMap.contains("creat"))
{
QDateTime createdTimestamp;
createdTimestamp.setTime_t(jsonMap["creat"].toUInt());
jsonCreatedTimestamp = jsonMap["creat"].toUInt();
createdTimestamp.setTime_t(jsonCreatedTimestamp);
jsonCreatedDateTime = createdTimestamp;
}
if (jsonMap.contains("plyrs"))

1
SnapmaticPicture.h

@ -90,6 +90,7 @@ private:
double jsonLocZ;
QString jsonArea;
QStringList jsonPlyrsList;
uint jsonCreatedTimestamp;
QDateTime jsonCreatedDateTime;
signals:

9
main.cpp

@ -93,6 +93,7 @@ int main(int argc, char *argv[])
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
{
EappTranslator.load(langpath + QDir::separator() + "/gta5sync_" + langList.at(0) + ".qm");
QLocale::setDefault(QLocale::system());
}
}
}
@ -113,6 +114,7 @@ int main(int argc, char *argv[])
}
else
{
QLocale::setDefault(QLocale(langList.at(0)));
svlp = true;
}
}
@ -134,6 +136,7 @@ int main(int argc, char *argv[])
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
{
EappTranslator.load(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm");
QLocale::setDefault(QLocale(langList.at(0)));
}
}
}
@ -235,6 +238,10 @@ int main(int argc, char *argv[])
if (svlp) { trsf = true; }
}
}
else
{
QLocale::setDefault(QLocale(langList.at(0)));
}
}
else
{
@ -254,6 +261,7 @@ int main(int argc, char *argv[])
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm");
QLocale::setDefault(QLocale(langList.at(0)));
}
}
}
@ -266,6 +274,7 @@ int main(int argc, char *argv[])
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm");
QLocale::setDefault(QLocale(langList.at(0)));
}
}
}

Loading…
Cancel
Save