loading globalMap into RAM

This commit is contained in:
Rafael 2016-04-23 21:01:00 +02:00
parent d60d9b8b72
commit 40eb28b65d
4 changed files with 23 additions and 1 deletions

View file

@ -28,6 +28,19 @@ GlobalString::GlobalString()
} }
QMap<QString, QString> GlobalString::getGlobalMap()
{
QMap<QString, QString> globalMap;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
globalFile.beginGroup("Global");
QStringList globalStrList = globalFile.childKeys();
foreach(const QString &globalStr, globalStrList)
{
globalMap[globalStr] = globalFile.value(globalStr, globalStr).toString();
}
globalFile.endGroup();
return globalMap;
}
QString GlobalString::getString(QString valueStr, bool *ok) QString GlobalString::getString(QString valueStr, bool *ok)
{ {

View file

@ -20,6 +20,7 @@
#define GLOBALSTRING_H #define GLOBALSTRING_H
#include <QString> #include <QString>
#include <QMap>
class GlobalString class GlobalString
{ {
@ -28,6 +29,7 @@ public:
static QString getString(QString valueStr, bool *ok = 0); static QString getString(QString valueStr, bool *ok = 0);
static QString getLanguageFile(); static QString getLanguageFile();
static QString getLanguage(); static QString getLanguage();
static QMap<QString, QString> getGlobalMap();
}; };
#endif // GLOBALSTRING_H #endif // GLOBALSTRING_H

View file

@ -68,6 +68,9 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) :
exportMenu->addAction(tr("Export as &GTA Snapmatic..."), this, SLOT(copySnapmaticPicture())); exportMenu->addAction(tr("Export as &GTA Snapmatic..."), this, SLOT(copySnapmaticPicture()));
ui->cmdExport->setMenu(exportMenu); ui->cmdExport->setMenu(exportMenu);
// Global map
globalMap = GlobalString::getGlobalMap();
installEventFilter(this); installEventFilter(this);
installEventFilter(ui->labPicture); installEventFilter(ui->labPicture);
ui->labPicture->setFocusPolicy(Qt::StrongFocus); ui->labPicture->setFocusPolicy(Qt::StrongFocus);
@ -158,7 +161,10 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu
plyrsList = picture->getPlayers(); plyrsList = picture->getPlayers();
picTitl = picture->getPictureTitl(); picTitl = picture->getPictureTitl();
picArea = picture->getArea(); picArea = picture->getArea();
picAreaStr = GlobalString::getString(picArea); if (globalMap.contains(picArea))
{
picAreaStr = globalMap[picArea];
}
QString plyrsStr; QString plyrsStr;
if (plyrsList.length() >= 1) if (plyrsList.length() >= 1)

View file

@ -68,6 +68,7 @@ protected:
private: private:
ProfileDatabase *profileDB; ProfileDatabase *profileDB;
Ui::PictureDialog *ui; Ui::PictureDialog *ui;
QMap<QString, QString> globalMap;
SnapmaticPicture *smpic; SnapmaticPicture *smpic;
QImage snapmaticPicture; QImage snapmaticPicture;
QString jsonDrawString; QString jsonDrawString;