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()
|
||||
{
|
||||
mutex.lock();
|
||||
return crewDB->childKeys();
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void CrewDatabase::addCrew(int crewID)
|
||||
{
|
||||
mutex.lock();
|
||||
crewDB->setValue(QString::number(crewID), crewID);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
~ProfileDatabase();
|
||||
|
||||
private:
|
||||
QMutex mutex;
|
||||
QSettings *profileDB;
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -90,6 +90,7 @@ private:
|
|||
double jsonLocZ;
|
||||
QString jsonArea;
|
||||
QStringList jsonPlyrsList;
|
||||
uint jsonCreatedTimestamp;
|
||||
QDateTime jsonCreatedDateTime;
|
||||
|
||||
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"))
|
||||
{
|
||||
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…
Reference in a new issue