thread-safe database classes, created instead of last modifed date in
title
This commit is contained in:
parent
419cd98cba
commit
1067fcf353
8 changed files with 28 additions and 2 deletions
|
@ -47,10 +47,14 @@ CrewDatabase::~CrewDatabase()
|
||||||
|
|
||||||
QStringList CrewDatabase::getCrews()
|
QStringList CrewDatabase::getCrews()
|
||||||
{
|
{
|
||||||
|
mutex.lock();
|
||||||
return crewDB->childKeys();
|
return crewDB->childKeys();
|
||||||
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrewDatabase::addCrew(int crewID)
|
void CrewDatabase::addCrew(int crewID)
|
||||||
{
|
{
|
||||||
|
mutex.lock();
|
||||||
crewDB->setValue(QString::number(crewID), crewID);
|
crewDB->setValue(QString::number(crewID), crewID);
|
||||||
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
#ifndef CREWDATABASE_H
|
#ifndef CREWDATABASE_H
|
||||||
#define CREWDATABASE_H
|
#define CREWDATABASE_H
|
||||||
|
|
||||||
|
#include <QMutexLocker>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QMutex>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
class CrewDatabase : public QObject
|
class CrewDatabase : public QObject
|
||||||
|
@ -32,6 +34,7 @@ public:
|
||||||
~CrewDatabase();
|
~CrewDatabase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QMutex mutex;
|
||||||
QSettings *crewDB;
|
QSettings *crewDB;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -214,7 +214,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu
|
||||||
|
|
||||||
if (crewID == "") { crewID = tr("No crew"); }
|
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));
|
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID, picTitl, picAreaStr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -47,15 +47,21 @@ ProfileDatabase::~ProfileDatabase()
|
||||||
|
|
||||||
QStringList ProfileDatabase::getPlayers()
|
QStringList ProfileDatabase::getPlayers()
|
||||||
{
|
{
|
||||||
|
mutex.lock();
|
||||||
return profileDB->childKeys();
|
return profileDB->childKeys();
|
||||||
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProfileDatabase::getPlayerName(int playerID)
|
QString ProfileDatabase::getPlayerName(int playerID)
|
||||||
{
|
{
|
||||||
|
mutex.lock();
|
||||||
return profileDB->value(QString::number(playerID), playerID).toString();
|
return profileDB->value(QString::number(playerID), playerID).toString();
|
||||||
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileDatabase::setPlayerName(int playerID, QString playerName)
|
void ProfileDatabase::setPlayerName(int playerID, QString playerName)
|
||||||
{
|
{
|
||||||
|
mutex.lock();
|
||||||
profileDB->setValue(QString::number(playerID), playerName);
|
profileDB->setValue(QString::number(playerID), playerName);
|
||||||
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
~ProfileDatabase();
|
~ProfileDatabase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QMutex mutex;
|
||||||
QSettings *profileDB;
|
QSettings *profileDB;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -56,6 +56,7 @@ SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : Q
|
||||||
jsonLocZ = 0;
|
jsonLocZ = 0;
|
||||||
jsonCrewID = 0;
|
jsonCrewID = 0;
|
||||||
jsonArea = "";
|
jsonArea = "";
|
||||||
|
jsonCreatedTimestamp = 0;
|
||||||
jsonPlyrsList = QStringList();
|
jsonPlyrsList = QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +346,8 @@ void SnapmaticPicture::parseJsonContent()
|
||||||
if (jsonMap.contains("creat"))
|
if (jsonMap.contains("creat"))
|
||||||
{
|
{
|
||||||
QDateTime createdTimestamp;
|
QDateTime createdTimestamp;
|
||||||
createdTimestamp.setTime_t(jsonMap["creat"].toUInt());
|
jsonCreatedTimestamp = jsonMap["creat"].toUInt();
|
||||||
|
createdTimestamp.setTime_t(jsonCreatedTimestamp);
|
||||||
jsonCreatedDateTime = createdTimestamp;
|
jsonCreatedDateTime = createdTimestamp;
|
||||||
}
|
}
|
||||||
if (jsonMap.contains("plyrs"))
|
if (jsonMap.contains("plyrs"))
|
||||||
|
|
|
@ -90,6 +90,7 @@ private:
|
||||||
double jsonLocZ;
|
double jsonLocZ;
|
||||||
QString jsonArea;
|
QString jsonArea;
|
||||||
QStringList jsonPlyrsList;
|
QStringList jsonPlyrsList;
|
||||||
|
uint jsonCreatedTimestamp;
|
||||||
QDateTime jsonCreatedDateTime;
|
QDateTime jsonCreatedDateTime;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
9
main.cpp
9
main.cpp
|
@ -93,6 +93,7 @@ int main(int argc, char *argv[])
|
||||||
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
|
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
|
||||||
{
|
{
|
||||||
EappTranslator.load(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
|
else
|
||||||
{
|
{
|
||||||
|
QLocale::setDefault(QLocale(langList.at(0)));
|
||||||
svlp = true;
|
svlp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,6 +136,7 @@ int main(int argc, char *argv[])
|
||||||
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
|
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
|
||||||
{
|
{
|
||||||
EappTranslator.load(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; }
|
if (svlp) { trsf = true; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QLocale::setDefault(QLocale(langList.at(0)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -254,6 +261,7 @@ int main(int argc, char *argv[])
|
||||||
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
|
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
|
||||||
{
|
{
|
||||||
appTranslator.load(":/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"))
|
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
|
||||||
{
|
{
|
||||||
appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm");
|
appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm");
|
||||||
|
QLocale::setDefault(QLocale(langList.at(0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue